30 Apr
2004
30 Apr
'04
7:06 p.m.
I'm converting our code to use lexical_cast for converting between our numeric types to string. It worked mostly but was surprised to see what looked like graphic characters on my screen. It turns out that when we wanted to display the ascii value of a character, lexical_cast<string> doesn't work -- it doesn't treat the char as a numeric, which when we really think about it, makes a lot of sense. Casting the char to int solves the problem. But I was just wondering how the experts would handle this. char c = 65; string s1 = lexical_cast<string>(c) // s1 = "A" string s2 = lexical_cast<string>((int)c) // s2 = "65" Thanks! -Jerry