I've got this (incorrect) sample code for getting a value out of stringstream and storing it in a byte-sized variable (it needs to be in a single byte var, not an int):
#include <iostream>
#include <sstream>
using namespace std;
int main(int argc, char** argv)
{
stringstream ss( "1" );
unsigned char c;
ss >> c;
cout << (int) c << endl;
}
The output when I run this is 49, which is not what I would like to see. Obviously, this is being treated as a char and not simple numeric value. What is the most c++ish way to get c to hold a 1 rather than a 49 when casted to an int?
Thanks!