Can ASCII code for a char be printed in C++ like in C? -
as can print ascii code , increment in c --> e.g:
{ char ch='a'; ch++; printf("%d",ch); }
this output "66" on console.
how can done in c++ ??
printf
work in c++. if want use cout
, need cast:
char ch = 'a'; ch++; std::cout << static_cast<int>(ch);
Comments
Post a Comment