Interview Question 3569

Created by admin on Sat, 17/11/2012 - 12:38
Explanation: 
Initialization should not be done for structure members inside the structure declaration.
Question: 

#include main()
{
struct xx
{
int x=3;
char name[]="hello"; };
struct xx *s=malloc(sizeof(struct xx));
printf("%d",s->x);
printf("%s",s->name);
}

Language: 
Answer: 

Compiler error: Cannot modify a constant value.