我需要确保我的代码中没有任何行超过一定的长度。
通常我会在有逗号或其他合适的换行符处分隔行。
我怎样才能把这条线分成2?
cout<<"Error:This is a really long error message that exceeds the maximum permitted length.\n";
如果我只是在中间的某个地方按 Enter,它就不起作用。
最佳答案
两种选择:
cout << "Error:This is a really long "
<< "error message that exceeds "
<< "the maximum permitted length.\n";
或者:
cout << "Error:This is a really long "
"error message that exceeds "
"the maximum permitted length.\n";
第二个效率更高。
关于c++ - 如何在 C++ 中拆分长行代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/969394/