I want to read then store the content of a file in an array, but this isn't working:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string content,line,fname;
cout<<"Execute: ";
cin>>fname;
cin.ignore();
cout<<endl;
//Doesn't work:
ifstream myfile(fname);
if(!myfile.is_open()){
cout<<"Unable to open file"<<endl;
}else{
while(!myfile.eof()){
getline(myfile,line);
//I don't know how to insert the line in the string
}
myfile.close();
}
cin.get();
return 0;
}