Output from debug:
File opened...
File contents:
Output from .exe (run via double click from /project/debug):
File opened...
File contents: line1 line2 etc. . .
Source code:
#include <iostream>
#include <fstream>
#include <regex>
#include <string>
#include <list>
using namespace std;
using namespace tr1;
int main()
{
string line;
list<string> dataList;
ifstream myFile("test_data.txt");
if (! myFile)
{
cout << "Error opening file. \n";
return 0;
}
else
{
cout << "File opened... \n";
while( getline(myFile, line) ) {
dataList.push_back(line);
}
}
cout << "\n\n File contents:";
list<string>::iterator Iterator;
for(Iterator = dataList.begin();
Iterator != dataList.end();
Iterator++)
{
cout << "\t" + *Iterator + "\n";
}
getchar();
return 1;
}
thank you for your help!
i now understand the problem, thank you. obviously, this also shows that this method of error handling for files is worthless. I have corrected that as well. Thanks again.