Char to String Conversion

Hi,

I'm converting a character to a string and using Stringstream:
1
2
3
4
5
 
string keystring;
stringstream ss;
ss << firstchar;
ss >> keystring;

It works fine except for when the character is a " " (space). If the character is a space it doesn't show up in the string. Any recommendations?

Cheers,
George
>> ignores spaces. You could use getline. Alternatively, you could
1
2
3
string str(1, firstchar);
//or
string str = (string() += firstchar);
Topic archived. No new replies allowed.