A->B += A->C[d]->B please help!!

A

almurph

Hi

Can anyone please explain this line of C code to me (with reference
to C#.Net, which is my main syntax). I'm confused!. code as follows:

*** begin confusion ***


A->B += A->C[d]->B


*** end confusion ***


Would appreciate any comments/suggestions/code-samples/C#.net
equivalents.
Thanks,
Al.
 
B

Bart

Hi

Can anyone please explain this line of C code to me (with reference
to C#.Net, which is my main syntax). I'm confused!. code as follows:

*** begin confusion ***


A->B += A->C[d]->B

Means:

A->B = A->B + A->C[d]->B

A->B means A is a pointer to a struct and B is a field in that struct (of
numeric/pointer type).

A->C[d] is the same pattern; the same struct has a field C which is an
array, presumably of pointers to structs (maybe the same struct, maybe a
different struct that also has a field B).

Doesn't C# have all this stuff too?
 
K

Kenny McCormack

Hi

Can anyone please explain this line of C code to me (with reference
to C#.Net, which is my main syntax). I'm confused!. code as follows:

*** begin confusion ***


A->B += A->C[d]->B


*** end confusion ***


Would appreciate any comments/suggestions/code-samples/C#.net
equivalents.
Thanks,
Al.

Leaving aside the fact that mentioning C# (and, by implication, that
evil company) is waving red flags in front of bulls, we have:

1) A must be a pointer to a struct (or union - hereinafter implied)
2) B and C must be the names of members of that struct (technically, of
the type of struct to which A points)
3) The member denoted by B must be some arithmetic type [*].
4) The member denoted by C must be an array of pointers to this struct type.

[*] That is, capable both of being incremented and of being an increment.

Putting it all together, we have that the B element of the struct to
which A points, is being incremented by ...

(Well, you work out what the RHS means)
 
H

Harold Aptroot

Bart said:
Hi

Can anyone please explain this line of C code to me (with reference
to C#.Net, which is my main syntax). I'm confused!. code as follows:

*** begin confusion ***


A->B += A->C[d]->B

Means:

A->B = A->B + A->C[d]->B

A->B means A is a pointer to a struct and B is a field in that struct (of
numeric/pointer type).

A->C[d] is the same pattern; the same struct has a field C which is an
array, presumably of pointers to structs (maybe the same struct, maybe a
different struct that also has a field B).

Doesn't C# have all this stuff too?

It does, see here:
http://msdn.microsoft.com/en-us/library/s8bz4d5h(VS.80).aspx
But it's not used very often, raw pointers are rare in C# and raw pointers
to structs (or arrays of them) more so.
I usually only use pointers in C# when I'm dealing with bitmaps or with
interop with some crazy native dll.
 
W

Wolfgang Draxinger

The following piece of logic may help to solve your confusion:

C# != C

So? The OP wanted some piece of C code explained in terms (C#) he
understands.

Wolfgang
 
R

rahul

A->B += A->C[d]->B
How about posting the structure of which A is an object.
* A is a pointer to structure
* C is a member of A which is an array of pointer to structures ?
* B is a numeric field ?

If you post your structure, the ? would be gone.

I don't know what you are working on but if you literally try to
translate between two different languages, its not going to work the
way you want it to. If porting is what you are looking at, then look
at the ends and not the means. C# does support raw pointers but I
haven't seen any real code using them. Also, the concept of structures
in C# is a bit different from structures in C.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top