For long line how to continue in next line

Hi,I am working on this https://www.codecademy.com/courses/learn-c-plus-plus/projects/build-a-text-adventure

I wonder if my condition for a for loop is too long to fit in one line and I want it type the rest of condition in the second line, what symbols to type to make it continue? I know something similar in python is “\”.
for example:

mystring ="this line too long to fit in one line this line too long to fit in one line this line too long to fit in one line \
this line too long to fit in one line"

So the C++ compiler doesn’t care if you skip lines (in the code) as long as end each line with a " and start the next one with a " .

#include <iostream>

void hello()
{
    std::cout << "Hello,"
                 " Bread!\n";
}

int main()
{
     hello(); //prints "Hello, Bread!"
     return 0;
}
3 Likes

Worth noting that you can do this in Python too, provided it’s within brackets/parentheses (string literal concatenation)…

mystring = (
    "this line too long to fit in one line this line too long to fit "
    "in one line this line too long to fit in one line this line too "
    "long to fit in one line"
)

it also works with f-strings and such too (in my opinion a far nicer option than \).

I am talking about a situation that inside for loop, the condition is too long, like this

for (int i=0; user_choice !='A' && user_choice != 'B' && user_choice!='C' && user_choice !='D' && i<3 ;i++){
}

That’s simpler then, it’s perfectly legal to break lines after && or ||.