To clarify:
This holds for C++-style strings (eg std::string), but not C-style strings (eg const char*, string literals, which are legal in C++ too).
Btw, this is an extremely simple question which we should not have had to answer.
You simply lack the thinking of a programmer, and this we cannot help you with. You must learn this.
I'd suggest you learn to use flowcharts and use them as an aid when writing your code to get your logic mixed into the code correctly.