opening/reading from a file
Hey guys, I cant get this file to open and Im not sure why. Any help would be appreciated
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
string fname, lname;
int month, day, year;
string text;
ifstream myfile ("president.txt");
myfile.open("/home/ohlone/Desktop/president.txt");
if (myfile.is_open())
{
while ( getline (myfile, text))
{
istringstream ss (text);
ss >> fname >> lname >> month >> day >> year;
cout << fname << "\t" << lname << "\t" << month << "\t"
<< day << "\t" << year << endl;
}
myfile.close();
}
else cout << "Unable to open file" << endl;
|
change lines 4 and 5 to these:
1 2
|
ifstream myfile;
myfile.open("president.txt");
|
Topic archived. No new replies allowed.