+ 1

What is the output of this? cout<<5+"SOLOLEARN";

Please specify with reason.

10th Feb 2019, 5:35 AM
Ishank Singh
Ishank Singh - avatar
3 Answers
+ 10
String literals are interpreted as char pointers pointing to the first character in the string. Adding 5 to the value of the address will shift the pointer 5 slots forward, pointing to character 'E'. Printing the string with 5 added to the string literal will hence print "EARN", starting from 'E', to the end of the string.
10th Feb 2019, 5:42 AM
Hatsy Rei
Hatsy Rei - avatar
0
hasty rei thanks
10th Feb 2019, 5:45 AM
Ishank Singh
Ishank Singh - avatar
0
This is actually amazing, never thought of that
30th Jan 2021, 1:34 AM
Sou o PeddoBear (PeddoRicko)
Sou o PeddoBear (PeddoRicko) - avatar