#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
char name[20];
int favoriteNum;
} person;
int main(){
person Gec = {"Gec", 1000}; //initialize var Gec of type struct person
Foo = (person) {"Foo", 7}; //initialize var Foo of type struct person
printf("%s's favorite number is %d.\n", Gec.name, Gec.favoriteNum);
printf("%s's favorite number is %d.\n", Foo.name, Foo.favoriteNum);
return 0;
}
Getting
"error: use of undeclared identifier 'Foo'".
Could it be that my version doesn't support using compound literals? Or am I doing something obviously wrong? Is the statement person Gec = {"Gec", 1000};
functionally the same as Gec = (person) {"Gec", 1000};
? Saw this in a lab assignment but it wasn't explained in detail.