Home > Blockchain >  I want to use cout more comfortably
I want to use cout more comfortably

Time:05-09

image

I want to use cout to print out this sentence: "You can build piramid which floor is only odd. not even", but I want to do it more comfortably. Just like the way below. But, when I use this way, an error occurs. So, is there any way to use it like this?

cout << "You can build piramid which floor is only odd.
        not even" << '\n';

CodePudding user response:

Adjacent string literals will automatically be concatenated, even if they are on different lines. So you can write it this way instead:

std::cout << "You can only build pyramids whose floor is odd, "
             "not even.\n";

CodePudding user response:

To use multi-line strings in C , you can use backslash.

 cout << "You can build piramid which floor is only odd. \
not even" << '\n';
  • Related