The initializer of a static variable must be known at compilation time. That’s why the declaration of bin is rejected. Instead you need to declare bin as a pointer to an integer and allocate memory dynamically, that is at run-time:
int *bin = malloc(size * sizeof *bin);
As pointed out by rioV8, you should also free the allocated memory with free(bin)
when you are done with bin.
2
solved Why VS Code, C build works but run code not? [closed]