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
Post a Comment