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

后端 未结 8 1727

Is there anyway to do something like PHP\'s

print << END
yadayadayada
END;

in C++? (multi-line, unescaped, easy-to-cut-and-paste stre

相关标签:
8条回答
  • 2021-01-02 00:19

    There is not such thing as a HEREDOC in C++.

    You can do

    cout << 
    "yadayadayada"
    "yadayadayada"
    << endl;
    

    That is the best you can get. But you still has to escape special chars like \,",'.

    The way would it be to include the text as an ressource into the executable or load it from an external file.

    0 讨论(0)
  • 2021-01-02 00:22

    If I understand you correctly, I believe you want this:

    #include <iostream>
    ...
    std::cout << std::endl << "yadayadayada" << std::endl;
    
    0 讨论(0)
提交回复
热议问题