Re: To get the size of a member of a struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eus wrote:
Is `sizeof(((struct person *) 0)->name)' the proper way to retrieve the size of a
member of a struct without declaring a variable of that struct as demonstrated in
the program below?

It should work, but may not be the best solution.

Another solution is to define a type you can query, e.g.
typedef char name_t[50];
and then use this in the struct definition and in the sizeof call.

Jim

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux