No they are notOriginally Posted by dirkfirst
Errm, you use them exactly the same way:
C:
typedef struct blabla
{
int x;
char z;
}
c++:
typedef struct blabla
{
int x;
char z;
}
Well, accually let me correct myself.
In some compilers ( Turbo C for example ), all C struct operations and declares must begin with `struct`:
But other than that you use them the exact same way.Code:typedef struct MNT_DEV{ byte oport; byte iport; }; void main(void) { struct MNT_DEV mnt_pt; struct mnt_pt.iport = 0x02; /* Normally mnt_pt.iport = 0x02; would be all you need */ }
So they are the same or they are not? lol
DirkFirst Tutorials | Linux Forum
yes, the only differnce is that sometimes c compilers will require you put the keyword "struct" infront of all structure operations, ie:
Code:struct header.i = 0; //Works header.i = 0; //Nope, no worky
I'd always thought the structure was the same, and it appears I was right, although I didn't know about that "struct" thing.
hi according to what i undrestand from the link jonh gave us there should a difference btw structs in C and c++
structs don't copy in C. That is, if a and b are structs then the line a = b; doesn't work. Nor will structs be fed into functions as arguments. The only way to deal with them sensibly is to use pointers to them, or to write functions to copy their elements explicitly
from :Differences between C and C++
Please don't bump years-old threads, kia!
ok but tel me make things clear first i didnt do this by porpose if i choosed these topic it is because i m actualy taking some course in struct i mean we reach the chapter about struct so this why anyway sorry and i didnt know that i may get warnig for this so sory then for this mistake![]()
hope my sory ll be accepted
Last edited by kia; 03-05-2008 at 03:30 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks