Jump to content

typedef struct help


3 posts in this topic

Recommended Posts

I got this bug in my head where I can't seem to understand what this is saying, I have checked three different books I have on typedef and struct but I don't know exactly what this code is doing.

 

Example code:

 

typedef struct point

{

int x;

int y;

} point_t;

 

Now I always thought if you wanted a structure of a certain type to be declared you just go:

 

typedef struct

{

int x;

int y;

} point_t;

 

What exactly is the first example doing with "point" and "point_t" or simply what happens with point? Cause I understand that later on I can declare:

 

point_t a, b;

 

but I basically have never seen a declaration of struct with an identifier after "typedef struct" and one after the closing "}"

 

Thanks for any help...

 

Laters

Link to comment
Share on other sites

I got this bug in my head where I can't seem to understand what this is saying, I have checked three different books I have on typedef and struct but I don't know exactly what this code is doing.

 

Example code:

 

typedef struct point

{

int x;

int y;

} point_t;

 

Now I always thought if you wanted a structure of a certain type to be declared you just go:

 

typedef struct

{

int x;

int y;

} point_t;

 

What exactly is the first example doing with "point" and "point_t" or simply what happens with point? Cause I understand that later on I can declare:

 

point_t a, b;

 

but I basically have never seen a declaration of struct with an identifier after "typedef struct" and one after the closing "}"

 

Thanks for any help...

 

Laters

 

In this thread you will find an answer:

http://www.thescripts.com/forum/thread620088.html

 

Pay special attention to post #5, it explains why sometimes you have to have named struct even if you are using typedef...

Link to comment
Share on other sites

 Share

×
×
  • Create New...