I am trying to send unsigned characters through a program, and I would like to be able to get the numbers through standard input (ie std::cin). For example when I type 2 I would like it send ☻ (unsigned char 2). when I use the code:
std::cout << "Enter values: ";
{
unsigned char d;
unsigned char e = 2;
std::cin >> d;
WriteFile(file, &d, 1, &written, NULL);
std::cout << "d= " << d << "\n";
std::cout << "e= " << e;
}
I get
Enter values: 2
d=2
e=☻
Can anyone tell me why d is being interpreted Incorrectly as unsigned char 50 while e is being interpreted correctly as unsigned char 2?
And of course after your explanation can You explain how to get User input and convert it so that I send 2 rather than '2'.