may i declare an array with a global element in C?
Can i declare with a const type? It runs on Xcode, however I fear it isn't correct, because glob is not a const type (same thought on static type).
#include <stdio.h> #include <stdilib.h> int glob; void main (){ int const con; static int stat; int arr[glob]; int arr2[con]; int arr3[stat]; } In addition, I'm in need of practicing finding mistakes in C code and correcting them for a test (CS student) and could not find a resource for it.
thank you in advance.
int const con;is useless, as the variable(!) is not initialised. C does not have symbolic constants like C++ or Pascal. They are all different languages. And writingconstafter the type is an obsolescence feature; writeconst int i = ...;instead.int glob; ...int arr[glob]is invalid ref asglobis 0.