This is my code:
typedef struct{
char name[64];
} Cat;
Cat createCat(char name[64]) {
Cat newCat;
int i;
for(i = 0; i < 64; i += 1) {
newCat.name[i] = name[i];
}
return newCat;
}
Cat exampleCat = createCat("Bob");
It compiles with the following error:
initializer element is not constant
What am I doing wrong?
You can’t do a method call here. Initialize
exampleCatsomewhere else.This is explained in the spec, section 6.7.8/4: