Getting a single, immediate character from the user is a platform-specific kind of thing to do. There are libraries that help minimize multi-platform problems (like NCurses), but for something simple you might as well just use the proper platform-specific code.
cout << "Please enter a filename to open (or only press enter to cancel)\n> " << flush;
getline( cin, filename );
cout << "Cancelled.\n";
ifstream f( filename.c_str() );