#include <stdio.h>
struct poly {
int len;
int arr[];
char *name;
};
int main() {
int i;
struct poly p;
p.len = 45;
p.arr[3] = {1,1,1};
p.name = "Josh";
printf("%d",p.len);
for(i = 0; p.arr[i] != NULL ; i++)
printf("%d",p.arr[i]);
printf("%s",p.name);
return 0;
}
I tried to make a simple program to see if I understood structures. Apparently, I do not. Haha.
I am getting these error messages when I compile:
struct.c:5: error: flexible array member not at end of struct
struct.c: In function âmainâ:
struct.c:14: error: expected expression before â{â token
Does anyone mind helping me learn what I did wrong and how to fix it?
Thank you!