isspace() is the way!
I have a "little" problem..
I want the user to input a string and a number value associated to it..
like this :
so I want to put those variable in a map<string,float>
so guessed I could put the first value all together in a temp string, then sort it out afterward.
using something like cin.get and isspace().
So basuically I need a way to go through a string until a white-space is encoutered. Put the first value into another string (map) and put whatever else is after in float(map)...?
You could use the default behavior of cin to your advantage...
cin will read up to a space and store it in temp_string, then store the rest in temp_float.
cout << "Please enter a string, and a float (example: pi 3.14): ";
cin >> temp_string >> temp_float;
// put them on the map or whatever
or just read char by char with cin.get() as you wish... then if the read char == ' ' just ignore it, what exactly is your problem?
ho didnt knew I could use cin that way (input 2 things on one line)
that should do it, thx.. :)
As for ammar Im just not sure how to read char by char.. :(