Why do I get numbers as output result when using wchar_t?
#include <iostream>
using namespace std;
int main()
{
wchar_t q;
q = 'A';
cout << q;
q = 'B';
cout << q;
q = 'C';
cout << q;
return 0;
}
Why do I get numbers as output result when using wchar_t?
#include <iostream>
using namespace std;
int main()
{
wchar_t q;
q = 'A';
cout << q;
q = 'B';
cout << q;
q = 'C';
cout << q;
return 0;
}
std::cout
is abasic_iostream<char>
. There is nooperator<<
overload forwchar_t
forbasic_iostream<char>
. When you outputwchar_t
objects they must be converted to some type for which there is anoperator<<
overload. The selected conversion is to an integral type other thanchar
and so the integral value is shown instead of the represented character.The displayed 'numbers' are the value of the character. That's the reason you get 'numbers'. If you want to display the characters you can use wcout