Reputation: 21
Essentially I'm trying to read certain lines from a .txt file and I made this function:
//Function to read specific lines of .txt files
std::fstream& GotoLine(std::fstream& file, unsigned int num)
{
file.seekg(std::ios::beg);
for (int i = 0; i < num - 1; ++i) {
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
return file;
}
I made the function inside main.cpp and outside the main function at the bottom, so I made sure to prototype it before the main function as such:
std::fstream& GotoLine(std::fstream& file, unsigned int num);
but when I try to use it inside the main function it gives an error saying: E0020: identifier "GoToLine" is undefined
This is how I use it inside the main function:
GoToLine(inFile, 8);
Upvotes: 0
Views: 1259
Reputation: 737
The error is simply because while calling the function you are calling GoToLine(inFile, 8);
with a capital " T " whereas in function definition it is small " t "
std::fstream& GotoLine(std::fstream& file, unsigned int num);
Upvotes: 2