c - Difference between typedef struct and struct? -


i know basic difference between them have doubt in particular situation following:

struct books{     int id;     char* title;       }book;  book.id=9;    // valid; 

but in case of typedef :

typedef struct books{   int id;   char*title; }book; book.id=9;    //it not valid have book b1; b1.id=9 valid 

what going on here can u tell me?

in first case, creating object of type struct books named book.

in second, defining alias book type struct books. book not object type name.


Comments

Popular posts from this blog

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

Why does PHP consider 0 to be equal to a string? -

formula - R: how to pass in a reference to the variable in glm or lm? -