I am trying to read the columns from a text file which look like
name number1*number2
why something like
Float_t value=0;
ifstream ifs("values.dat");
string line;
while(std::getline(ifs, line)) // read one line from ifs
{
istringstream iss(line); // access line as a stream
string dataname;
ifs >> dataname >> value; // no need to read further
but it fails to read the "*number2" part ie it passes to xs
only the number1
value. How can I fix this ?
In the absence of whitespace around the operator you can read the asterisk as a single
char
:Demo.