I am unable to understand how the size_1
variable calculates the size of the data member name. Could someone explain (((struct cheese_msgbuf*)0)->name);
what this line means and does?
#include<stdio.h>
struct cheese_msgbuf {
long mtype;
char name[20];
};
int main() {
/* calculate the size of the data to send: */
struct cheese_msgbuf mbuf;
int size;
int size_1;
size = sizeof(mbuf.name);
printf("Using just sizeof operator: %d\n", size);
/* Or, without a declared variable: */
size_1 = sizeof(((struct cheese_msgbuf*)0)->name);
printf("Using pointer: %d\n", size_1);
}