Iam beginner in c++ , so why this happens
for Example :
char b = 48; // cout's 0
char b = '48'; // cout's only 8
Iam beginner in c++ , so why this happens
for Example :
char b = 48; // cout's 0
char b = '48'; // cout's only 8
char b = 48; // cout's 0
This output 0 because the character 0 has ASCII value of 48.
char b = '48'; // cout's only 8
This output 8 because you can only have one character in char type varibale.
When you assign an integer to a character type variable, the variable stores the character defined by the integer(assuming it's an ASCII code).
But when you are assigning character type data in a character type variable, it stores the last assigned character to the variable.