Sunday, 15 February 2015

c++ - Assign 2 char to an int -


I am trying to understand the consequences of this code:

  # include & Lt; Iostream & gt; using namespace std; Int main () {int a = 'dd'; Cout & lt; & Lt; a; Return 0; }  

The result is 25700. How does the compiler get this number? Thanks

ascii code for 'd' is 0x64 literally by your compiler 'dd' was represented as 0x6464, which is 25700 when written in decimal notation.


No comments:

Post a Comment