Answer the question
In order to leave comments, you need to log in
Need to understand what the code means and what will be displayed on the screen?
char c[] = "1234567890";
short* a = (short*)c;
std::cout << *(a + 2) << std::endl;
Answer the question
In order to leave comments, you need to log in
Run and see: https://www.onlinegdb.com/online_c++_compiler . Try changing one character at a time and see what happens with the output. So you will understand what exactly is being output, and then a little knowledge of C and you will understand why this happens.
You need to understand what arrays and string constants are in C++, as well as pointers and address arithmetic. After that, you will understand exactly what is happening.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question