I am trying to write a program that will read just the first line of my textfile and then input that number into an int variable. But im confused as how to do it.
int highscore; // Starting highscore
ifstream myfile ("highscore.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline(myfile,highscore);
cout << highscore << endl;
}
myfile.close();
}
But for some reason im getting the error. |25|error: no matching function for call to 'getline(std::ifstream&, int&)'|
If you replace the getline with:
You’ll be able to read an int into highscore. Are you required to use getline?