Answer to Question #15393 in C++ for Vineet
Note: within single quotes only two characters
Usually you put only a single character between single quotes. Like 'R' or 's' or '4'. Those are the same as the values 82, 115 and 52, respectively. I.e. their ASCII values.
But integers can be bigger than 255. So you can keep adding chars between the single quotes. And those additional chars fill up the more significant bytes. So 'aa' are two bytes, each the value 97 (ASCII code for lowercase a), and the more significant byte is multiplied by 256.
So you get 97 * 256 + 97, which is - you may have guessed it - 24929.
But you shouldn't use more than one char between single quotes in your programs, because they might not be portable. The reason is endianness. I.e. how different architectures order their bytes (least significant byte first or most significant byte first).
You're welcome. We are glad to be helpful.
If you really liked our service please press like-button beside answer field. Thank you!
Thank you very much for the explanation.