I've been writing C for years now, but I've never learned how to structure things. I've just made giant programs in one file and used global scope for variables that are modified by multiple functions. I'm trying to break away from this and group my functions in separate files. The biggest problem I've had is with variable scope.
For example, one variable needs to be written to by two separate functions in different files and read by two more. I could declare it in main.c and make it an extern in the others, but I know globals are frowned upon and it seems sloppy.
So, is there a logical, "correct" place to declare it? Should it have something like get/set functions? Or is this problem indicative of me poorly dividing my functions?
Thanks.