[SOLVED] How to print ascii value of charecter in c++? Using cout | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

[SOLVED] How to print ascii value of charecter in c++? Using cout

With printf, we write printf("%d", c); where c is character ... but cout << c prints character's original value

23rd Nov 2016, 1:49 PM
Joseph Kishore Immandi
Joseph Kishore Immandi - avatar
4 Answers
+ 3
Just cast char to int: std::cout << int(ch);
23rd Nov 2016, 1:56 PM
Ondřej Doněk
Ondřej Doněk - avatar
+ 2
think u
23rd Nov 2016, 2:05 PM
Joseph Kishore Immandi
Joseph Kishore Immandi - avatar
+ 2
sorry thank u
23rd Nov 2016, 2:05 PM
Joseph Kishore Immandi
Joseph Kishore Immandi - avatar
0
No thanks :) That was simple answer to simple question.
23rd Nov 2016, 2:14 PM
Ondřej Doněk
Ondřej Doněk - avatar