in C a char var uses 1 byte in memory, and a int var uses 4 bytes in memory.
I have a structure with a char field and with a int field, so the sizeof function should return 5, but it returns 8.
#include <stdio.h>
#include <stdlib.h>
struct fileHeader {
char tipo;
int asdf;
};
int main()
{
printf("%d", sizeof(struct fileHeader));
printf("\n%d", sizeof(char));
printf("\n%d", sizeof(int));
/*
char word[]="\x6d\x6f\x64\x65\x6d";
printf("%s\n", word);
*/
system("pause");
return 0;
}
There are 3 bytes that should not appear, what is going on?.
Thanks.
ps: i am using dev-c++.

New Topic/Question
Reply



MultiQuote






|