if (!InpFile) {
cerr << "Unable to open the file StudentYear2010.txt" << endl; //show an error if file not found
exit(1);
}
I used this code to see if the files opened or not and this error never popped up when I had no pre created file. Doing a windows search also didn't find the file.
Does ifstream.file("Text.txt"); even compile?
If you meant ifstream file("Text.txt"); then it won't create it for you if the file doesn't exist, and your error text should have popped up. If you open it using std::ofstream or with std::fstream with std::ios_base::out flag set, then it should create it.