一、多行输出
也许你认为,
C++
实在弱到连多行输出都要不停写cout
和endl
、"\n"
。有时候,C++
甚至不能Ctrl+C和Ctrl+V的厌烦症。好吧,不知情的你可能会写出这种程序:#include <iostream> using namespace std; int main() { cout << "####\n"; cout << "#**#\n"; cout << "#**#\n"; cout << "####\n"; // 更多cout语句… return 0; }
其实,我们可以用
C++
提前给我们准备的函数R"()"
:#include <iostream> using namespace std; int main() { cout << R"(#### #**# #**# #### …)" return 0; }
Ctrl+C和Ctrl+V的追捧者,现在你们知道如何运用了吧。