Another apporach would be to use getline. Something like this should work
string filename;
cout << "Enter the filename: ";
getline(cin, filename);
ifstream OpenFile(filename.c_str());
//...
You will need to add #include<string>
to your code for this to work. Also you are using the headers you have are depreacted. You have
#include <iostream.h>
#include <fstream.h>
// change that to this
#include <iostream>
#include <fstream>
BTW what compiler are you using?