[Solved] File “not declared in scope” even though it was [closed]


EDIT: Since according to the OP, the code is in a function, and score is defined, this is more than likely a case of the computer
being a jerk. Restart should theoretically solve the problem.

The code’s logic is correct as it stands. Syntactically, there are two major problems: it must be in a function, and score has to be defined, (though that’s unrelated to this error).

I’m going to take a guess that you’re coming from a language like Python, where you can run code straight. As Nathan Oliver and Fabio Turati pointed out, you appear to lack an int main() function, which is required for all C and C++ programs.

Check out the documentation for ofstream to see a working version of your code.

16

solved File “not declared in scope” even though it was [closed]