Can someone pls explain me why this wont work?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
struct S {
int i;
double d;
const char * s;
};
int main() {
S s1 = { 3, 47.9, "string one" };
printf("s1: %d, %f, %s\n", s1.i, s1.d, s1.s);
return 0;
}
| |
Error list:
Error C2628 'S' followed by 'int' is illegal (did you forget a ';'?) line 7
Error C2079 'i' uses undefined struct 'S' line 7
Error C2059 syntax error: '}' line 10
Error C2143 syntax error: missing ';' before '}' line 10
Error C2079 's1' uses undefined struct 'S' line 14
Error C2440 'initializing': cannot convert from 'initializer list' to 'int' line 14
Error C2079 's2' uses undefined struct 'S' line 15
Error C2440 'initializing': cannot convert from 'initializer list' to 'int' line 15
Warning C4473 'printf' : not enough arguments passed for format string line 18
Error C2143 syntax error: missing ')' before ';' line 18
Warning C4477 'printf' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'int'
Warning C4313 'printf': '%s' in format string conflicts with argument 1 of type 'int'
Warning C4473 'printf' : not enough arguments passed for format string