struct BOOK
{
char name[120];
char author[120];
int year[50];
};
int main (void)
{
int i;
int number;
struct BOOK* books;
number = 50000;
printf("before \nsizeofbooks %d \n sizeofBOOK %d\n",
sizeof(books), sizeof(struct BOOK));
books = (struct BOOK*)malloc(sizeof(struct BOOK) * number);
printf("sizeofbooks %d \n sizeofBOOK %d\n",
sizeof(books), sizeof(struct BOOK));
free(books);
return 0;
}
the output is:
before
sizeofbooks 4
sizeofBOOK 440
after
sizeofbooks 4
sizeofBOOK 440
It always outputs 4, even if I write to a different array, but I would expect it to change. What am I doing wrong?
My os is winxp 32 bit and I use codeblocks.