initialize the struct pointer
c, initialization, struct
Solution
We can initialise the structure with pointer as below
example:
int i;
char e[5]="abcd";
EXE *p=malloc(sizeof(*p));
for(i = 0;i < 5;i++)
*(p+i)=(EXE){e,i+48};
Problem
``` typedef struct { char *s; char d; }EXE; EXE *p; ``` For the above `struct` how do I initialize the structure with pointer? I know for a non-pointer we do `EXE a[] = { {"abc",1}, {"def",2} };` . Similarly Is it possible with a pointer after allocating the memory? Say like `p[] = { {"abc",1},.. so on}` . Basically I want to initialize dynamically. Thanks.