with file exists check:
Code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
*cout<<"Which file do you want to open?" << endl;
*string name;
*cin >> name;
*cout << "Opening "<< name << "..." << endl;
*ifstream file (name.c_str());
*if(!file) {
* * cout <<"file: "<< name << " doesn't exist" <<endl;
* * return 1;
*}
*cout << file.rdbuf();
*cin.get();
*return 0;
}