Do you guys know why it output the sizeof g isCode:char g[10]; /*ten bytes*/ int main() { struct g { int a; }; printf("g is supposed to be (4)sizeof(a) %d",g); return 0; } Output display g = 10.
equal to 10 instead of 4?
This code was compiled with GCC compiler.
Can anyone explain concisely about this??
Thanx!
P.S:
As I know in C if the local variable is the same
name with global variable then that name become
locally access in the scope where it define.
For ex:
int a=1;
void fun()
{ int a=10;
int b;
printf("a value should be (10): %d",a);
}
int main()
{
fun();
return 0;
}