int main()
{
int i;
typedef struct {
int no[6];
int socket;
}data;
data *a = {
a->no[6] = {0},
a->socket= 3,
};
printf( "no[0] = %d\n",a->no[0]);
printf("socket = %d\n", a->socket);
getchar();
return 0;
}
In this simple code, I have created a structure and initializing it using structure pointer - assigning 0 value to all elements of array 'no' and value 3 to variable socket. I am getting error as : error C2440: 'initializing': cannot convert from 'initializer list' to 'data *' note: The initializer contains too many elements
where am I going wrong? I also tried with
data a = {
a.no[6] = {0},
a.socket= 3,
};
printf("no0 = %d\n",a.no[0]);
printf("socket = %d\n", a.socket);
here the code is running but showing a.socket = 0 instead of 3.