Answer the question
In order to leave comments, you need to log in
Code not compiling?
An error occurs while compiling this code.
#include <stdio.h>
struct {
int debug;
} config;
config.debug=1;
int main() {
printf("%d",config.debug);
return 0;
}
ain.c:6:1: error: unknown type name 'config'
config.debug=1;
^
main.c:6:7: error: expected identifier or '('
config.debug=1;
^
2 errors generated.
Answer the question
In order to leave comments, you need to log in
Your assignment operation lies outside the function. The compiler waits there for declarations of variables, functions, types, that's all, and you have an operation there. Move the assignment to main().
If you want to initialize a structure, you can use an initialization list:
struct {
int debug;
} config = {1};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question