code does not work
This code does not work, can somebody tell me why?
(fileName is a global string and linesInFile is a global vector of strings)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <cstdlib>
void loadFile()
{
ifsteam myfile(fileName.c_str());
string line;
if(myfile.is_open())
{
while(!myfile.eof())
{
getline(myfile, line);
linesInFile.push_back(line);
}
myfile.close();
}
else
{
cout << "Unable to open file." << endl;
exit(EXIT_FAILURE);
}
return;
}
|
Thanks.
Last edited on
If you are asking why it doesn't compile, you spelled "stream" wrong on line 9.
Topic archived. No new replies allowed.