Why does the following snippet of code output only one symbol? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why does the following snippet of code output only one symbol?

cout << *("Hello!"); // H

2nd Mar 2019, 9:39 PM
coding-space.ru
coding-space.ru - avatar
1 Answer
+ 2
Every string is an array of char. "Hello!" is in fact an Adress to an array of char. So, doing *("Hello!") takes the first value of that array and outputs it.
2nd Mar 2019, 10:21 PM
Théophile
Théophile - avatar