G
gokrix
#include <stdio.h>
#include <stdlib.h>
struct s
{
int i;
char c;
float f;
};
int main()
{
printf("addr is [%p]. \n", &(((struct s*)0)->c));
return EXIT_SUCCESS;
}
When I compile (gcc -g -W -Wall -ansi -pedantic) and run the above code,
it prints "addr is [0x4].". If I change to 0 to 100, it prints 104.
Why?
Which part of the standard mandates this behaviour?
Thanks,
--GS
#include <stdlib.h>
struct s
{
int i;
char c;
float f;
};
int main()
{
printf("addr is [%p]. \n", &(((struct s*)0)->c));
return EXIT_SUCCESS;
}
When I compile (gcc -g -W -Wall -ansi -pedantic) and run the above code,
it prints "addr is [0x4].". If I change to 0 to 100, it prints 104.
Why?
Which part of the standard mandates this behaviour?
Thanks,
--GS