T
Tagore
hi,
Please consider 2 programs below and queries assoicated with them:
PROGRAM-1:
#include<stdio.h>
typedef union
{
float f1;
float f2;
int i;
}sample;
int main()
{
sample S={66};
printf("%f %f %d",S.f1,S.f2,S.i);
return 0;
}
OUTPUT:
66.000000 66.000000 1115947008
I feel myself unable to understand above output...I expected that as
we are initializing S with 66 ,a integer, so It should print first two
grabage value when printing floating values.and then print 66 but I
found it otherwise here.
PROGRAM-2:
#include<stdio.h>
typedef struct sample
{
int i;
char a[10];
}data;
int main()
{
printf("%d", sizeof(data.a));
return 0;
}
OUTPUT:
In function 'main':
Line 10: error: expected ')' before '.' token
I expected output of this function to be 10 which is size of array
a....but could not understand this error.
Please help me regarding both queries
Please consider 2 programs below and queries assoicated with them:
PROGRAM-1:
#include<stdio.h>
typedef union
{
float f1;
float f2;
int i;
}sample;
int main()
{
sample S={66};
printf("%f %f %d",S.f1,S.f2,S.i);
return 0;
}
OUTPUT:
66.000000 66.000000 1115947008
I feel myself unable to understand above output...I expected that as
we are initializing S with 66 ,a integer, so It should print first two
grabage value when printing floating values.and then print 66 but I
found it otherwise here.
PROGRAM-2:
#include<stdio.h>
typedef struct sample
{
int i;
char a[10];
}data;
int main()
{
printf("%d", sizeof(data.a));
return 0;
}
OUTPUT:
In function 'main':
Line 10: error: expected ')' before '.' token
I expected output of this function to be 10 which is size of array
a....but could not understand this error.
Please help me regarding both queries