Vidyalelo
C Programming · Q24

C Miscellaneous

Programming · C Programming · question 24

Q24

Determine Output: void main() struct xx int x=3; char name[] = "hello"; ; struct xx *s = malloc(sizeof(struct xx)); printf("%d", s->x); printf("%s", s->name);

A.
3 hello
B.
Compiler Error
Answer
C.
Linking error
D.
None of these

Answer: Option B

Solution

Answer: Option B
Solution:

Initialization should not be done for structure members inside the structure declaration.