Something like print END << END; in C++?

This answer is now out of date for modern C++ - see sbi's answer for the modern way.

This is the best you can do:

std::cout <<
    "This is a\n"
    "multiline\n"
    "string.\n";

Not as convenient as a proper heredoc, but not terrible.


C++11 has raw string literals:

// this doesn't have '\n', but '\\' and 'n'
R"(yada"yadayada\n)" 

And if you need those parens, you can do that, too, using whatever you want for an end token:

// the following will be "(yada)(yada)(yada)"
R"END((yada)(yada)(yada))END" 

it also works with embedded new lines:

// the following will be "\n(yada)\n(yada)\n(yada)\n"
R"END(
(yada)
(yada)
(yada)
)END"