Sep 24, 2010

resolve multiple numbers from getline string

string datafile = "e:\\reg.txt";
int pos;

ifstream datastream;
datastream.open(datafile.c_str(), ios.binary);

if (!datastream.is_open()) {
cout<< "Data files not opened, end of running!";
exit(0);
}

string myString;
while(getline(datastream,myString)){
vector str;
std::istringstream iss(myString);
while(iss){
iss >> pos;
str.push_back(pos);
}

data.push_back(str);
}

No comments:

Post a Comment