reading from file

Hello everybody,
I've got an input file,which consists of 400 integers seperated by spaces i wanna read them to my program what should i do to read them as integers.
PLZ HELP ME!!!!!
Last edited on
try this:

string a;

while(!file.eof())
{
getline (file, a, ' ')
cout << a << "\n";
}

1
2
3
4
5
6
7
ifstream input("someFile");
std::string temp;
while(1)
{
  input >> temp;
  std::cout << temp << std::endl;
}


Don't forget to do something to exit the loop at the end of the file.
Also don't forget the #include <fstream> at the top of your file either.
Topic archived. No new replies allowed.