Possible Duplicate:
C++ - repeatedly using istringstream
Given this code :
string line; // for the line
ifstream myfile ("input.txt");
int algorithmNumber , matrixDim;
getline (myfile,line);
istringstream buffer(line);
buffer >> algorithmNumber;
I read one line and then convert that line from string to int .
But if I want to read the next line and do that again :
buffer(line);
buffer >> matrixDim;
I get this : no match for call to '(std::istringstream {aka std::basic_istringstream<char>}) (std::string&)'
How can I read the next line and convert it into int with istringstream
?
Regards