Does *&s1 refer to the first member of structure variable s1
- From: "lovecreatesbea...@xxxxxxxxx" <lovecreatesbeauty@xxxxxxxxx>
- Date: Thu, 05 Jul 2007 07:24:20 -0700
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
$
*/
.
- Follow-Ups:
- Re: Does *&s1 refer to the first member of structure variable s1
- From: Eric Sosman
- Re: Does *&s1 refer to the first member of structure variable s1
- From: Jens Thoms Toerring
- Re: Does *&s1 refer to the first member of structure variable s1
- Prev by Date: Re: Redirecting input from file
- Next by Date: Re: Redirecting input from file
- Previous by thread: Re: sample for base64 encoding in c language
- Next by thread: Re: Does *&s1 refer to the first member of structure variable s1
- Index(es):
Relevant Pages
|