+ 13
Can we use the features of writing character values for a given integer as in c in c++?
printf("%c",65);//outputs A in c printf("%d",'B');//outputs 66 in c without using typecast,is there other methods available in c++?
1 Answer
+ 3
#include <iostream>
int main()
{
char x = 42;
std::cout << +x << "\n"; // prints 42
std::cout << x << "\n"; // prints *
}