N
N
nikita_yakovlev20052021-09-09 16:39:28
C++ / C#
nikita_yakovlev2005, 2021-09-09 16:39:28

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

2 answer(s)
W
Wataru, 2021-09-09
@wataru

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.

D
Denis Zagaevsky, 2021-09-09
@zagayevskiy

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 question

Ask a Question

731 491 924 answers to any question