so i'm writing up a little program for a text-based game i might make in the future. it's a combat system (turn-based) and there's a lot of stuff inside the file so i'd rather keep it separate from the source file.
i was wondering if there was a way to define the whole thing as a function, define the variables in the source file, and then just call the function whenever it's needed.
i was wondering if there was a way to define the whole thing as a function
Yes, you can do that, but it doesn't sound like a good idea to to put the whole thing in a single function.
You should focus on creating small functions that do specific things. You can put those functions in a separate file and compile them separately. Create a .cpp file for your separate functions. Create a .h file that includes function prototypes for the functions in your separate file. Include the header in both your separate file and your main.