I tried to replace the stringstream with input from the keyboard. Here is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
char ss;
cout << "Please insert something separated with : " << endl <<;
cin >> ss;
while (ss) {
string name;
int value;
getline( ss, name, ':' );
ss >> value;
ss.ignore( numeric_limits<streamsize>::max(), '\n' );
cout << name << ": " << value << endl;
}
The following error appeared:
1 2
error: no matching function for call to 'getline(char&, std::string&, char)'
error: request for member 'ignore' in 'ss', which is of non-class type 'char'
My next step was to read the input from a file. That works fine. It also reads the string and ignore the ':' but the output of the value is strange. I don't know what the output of the value means.
As you can see the program reads the 2 lines perfectly. I just don't understand the output of the value; it should be 15.00 and 20.00. Any help is appreciated. Thanx!