L
lovecreatesbea...
Does the expression *(int *)&s1 below inside the printf() statement
guarantee to refer to the first member of the structure variable s1?
I've tried the code and it seems that it works that way. The C
standard states this? Thank you very much.
#include <stdio.h>
struct S{
int m1, m2, m3;
};
int main(void)
{
struct S s1 = {3, 4, 5};
printf("%d\n", *(int *)&s1);
return 0;
}
/*
$ gcc -ansi -pedantic -W -Wall a.c
$ ./a.exe
3
$
*/
guarantee to refer to the first member of the structure variable s1?
I've tried the code and it seems that it works that way. The C
standard states this? Thank you very much.
#include <stdio.h>
struct S{
int m1, m2, m3;
};
int main(void)
{
struct S s1 = {3, 4, 5};
printf("%d\n", *(int *)&s1);
return 0;
}
/*
$ gcc -ansi -pedantic -W -Wall a.c
$ ./a.exe
3
$
*/