Hey guys, the following code simply won't work for me?
The file is there, I have tried both the way it currently is, and also using the full file path, neither seem to work.
Any ideas? Thanks guys.
EDIT: It keeps saying Program received signal: "SIGABRT".
The file is there, I have tried both the way it currently is, and also using the full file path, neither seem to work.
Code:
// reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("example.txt");
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
Any ideas? Thanks guys.
EDIT: It keeps saying Program received signal: "SIGABRT".