M
Mastupristi
I want to obtain the c++ equivalent of:
unsigned short us = 347;
printf("0x%04hX",us);
that outputs "0x015B"
I ried with:
cout.setf(ios_base::hex,ios_base::basefield);
cout.setf(ios_base::showbase);
cout.width(6);
cout.fill('0');
cout << 347 << endl;
But I obtain "00x15b"
Then I tried to modify:
cout.setf(ios_base::hex,ios_base::basefield);
cout << "0x";
cout.width(4);
cout.fill('0');
cout << 347 << endl;
and obtain "0x015b", but I want uppercase characters.
How can I obtain what I want in a simple way using cout?
thanks
unsigned short us = 347;
printf("0x%04hX",us);
that outputs "0x015B"
I ried with:
cout.setf(ios_base::hex,ios_base::basefield);
cout.setf(ios_base::showbase);
cout.width(6);
cout.fill('0');
cout << 347 << endl;
But I obtain "00x15b"
Then I tried to modify:
cout.setf(ios_base::hex,ios_base::basefield);
cout << "0x";
cout.width(4);
cout.fill('0');
cout << 347 << endl;
and obtain "0x015b", but I want uppercase characters.
How can I obtain what I want in a simple way using cout?
thanks