+ 1
String addition?
So a question in a C++ challenge asked what the output of cout << 1 + "hello"; (or whatever the string was, it's not important) would be, I went to find out and the output was "ello" Why?
2 Answers
+ 2
"hello"'s type is const char *.
Pointer's pointing to first letter.
+1: second letter.
+ 1
This is something called pointer arithmetics... When you define a literal string, compiler get you a pointer to a sequence of characters in memory. This pointer is an adress, a number, and as such you can add numbers to it. Adding a number here mean "get the adress of char advancing by i chars"