I'm a newbie to C++. Small code sample follows:
int main(int argc, char* argv[]) {
char ch1;
int int1;
cin >> ch1;
cin >> int1;
cout << ch1 << '\n';
cout << int1 << '\n';
return 0;
}
When I run the program and input the following:
az
I get as output:
a 32767
I understand the 'a' but why the integer value of 32767? I just want to test and see what happen if instead of a numeric value assigned to int1 i used a 'z'.
I try inputting:
ax
...and I also get same results.
Now if instead of int int1
I use short int1
and run the program with input:
az
I get the output:
a 0
P.S.
sizeof(int) = 4
sizeof(short) = 2
I am using a 64-bit machine.