Which topic should I study to understand this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Which topic should I study to understand this?

https://code.sololearn.com/cm9aVhdl7l0r/?ref=app

6th Aug 2018, 5:55 AM
Uttam
Uttam - avatar
9 Answers
+ 7
Pointers?
6th Aug 2018, 6:19 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
Borislav Kalinski but it is a const char pointer, not a string object, try to call a method (e.g. "SoloLearn".length()) on it, it will not work. That line output a copy of "SoloLearn" starting from index 5 which gives "earn" the same result can be obtained with such call: cout << (const char*) "SoloLearn" + 5; Please correct me if I'm wrong.
6th Aug 2018, 8:17 AM
Ipang
+ 4
Thanks Ipang, Pegasus and Borislav.
6th Aug 2018, 3:40 PM
Uttam
Uttam - avatar
+ 3
Borislav Kalinski no need to apologize my friend, we are all here to learn, it's OK. Cheers!
6th Aug 2018, 3:38 PM
Ipang
+ 2
Strings Because this is not a pointer. The logic is "something" + "something" = "somethingsomething" "word" + 5 = "word5" 5 + "word" = error
6th Aug 2018, 6:54 AM
B K
+ 1
Sorry I am wrong. Well I have to read again about pointers. Thanks for correcting me Ipang.
6th Aug 2018, 3:19 PM
B K
+ 1
Uttam you cannot combine an integer and a string, if you want it to say "5Sololearn", then cover the 5 in quotes.
6th Aug 2018, 6:17 PM
Will
Will - avatar
0
this is a pointer. If you want to write 5Sololearn just write that ; cout<<"5 Sololearn; I GUESS YOU MUST REVIS. YOU LESSONS AT C++ and that's all.
7th Aug 2018, 12:25 AM
Feres
Feres - avatar
0
Also Uttam, the reason it prints "earn" is because 5 is the 6th place in the string (0, 1, 2, 3, 4, 5) and it acts like an arry. If you did cout << 4 + "SoloLearn", the output would be Learn instead of earn.
7th Aug 2018, 12:39 AM
Will
Will - avatar