I get a compile error when I try to assign the struct with the array size of a global variable which the user will input in at the command line, and then pass the value back to the variable that was declared globally.
Here is just sample code:
#include <stdlib.h>
#include <stdio.h>
int Type;
struct list_el {
int val;
} list1[Type];
struct list_el item;
int main() {
Type = 10; // Just a sample
}
Error:
variable modified at file scope Struct C
Is there a way to fix the problem? I need it to work globally.