+ 3

How i print the ascii code of an character with Cout ?

29th Jan 2017, 4:08 PM
aziz
aziz - avatar
4 Respostas
+ 5
Cast it to int Test: char a =44; cout << a << (int)a << endl;
29th Jan 2017, 4:59 PM
Mattias Eriksson
Mattias Eriksson - avatar
+ 7
If you don't want to output using cout, then you'll have to use printf(), which I highly not recommend.
29th Jan 2017, 4:44 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
printf("a = %d \n", 'a'); like this
29th Jan 2017, 8:27 PM
aziz
aziz - avatar