Ok. I need to import a text file called LOG.DAT and I'm having some trouble. I can't figure out where to put the file 'flag'...I guess, that tells you what to do with the file, like read, write, or read and write. The compiler keeps spitting out this "136 variable `std::ifstream logfile' has initializer but incomplete" crap. I'm pretty sure I've read this issue in an earlier article in the forum, but I can't find it anymore. Here's the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
if (mainMenu == 'v' ||
mainMenu == 'V')
{
string line;
ifstream logfile ("data\\log.dat");
if (logfile.is_open())
{
while (! logfile.eof() )
{
getline (logfile,line);
cout << line << endl;
}
logfile.close();
}
else cout << "Unable to open file";
}