For some reason, my program is skipping the code fragments cin.get(); and cin.ignore();. I do not know why this is happening, because the two fragments work fine when just inside the main() scope, and not in the if statement.
Here is the relevent code fragment:
input.open(inputFileName);
if (input.fail())
{
cout << "Error: failed to open '" << inputFileName << "'.\n\n";
cout << "Press '' to end the program...";
cin.get(); //cin.ignore() also does nothing.
input.close();
exit(1);
}
The rest of the source code can be found here: http://pastebin.com/xy0qMvBq
With that command, the user is going to type some “stuff”, and then hit enter. That’s going to put the “stuff”, plus a newline character into the input buffer. Then the “stuff” is going to get stored into inputFileName, and the newline character is going to be left there. This is what cin.get() and cin.ignore() read, they are not being skipped.