c++ - 如何在 C++ 中拆分长行代码?

标签 c++ split

我需要确保我的代码中没有任何行超过一定的长度。

通常我会在有逗号或其他合适的换行符处分隔行。

我怎样才能把这条线分成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/

相关文章:

c++ - friend 和内联方法,有什么意义?

java - 字符串分词

excel - 将一列拆分为多列

c++ - 在Xcode和Visual Studio之间移动的问题

c++ - <未解析的重载函数类型> 调用二元谓词

c# - 拆分功能设置

python - ZSH 5.05 字符串拆分为空

python - 将名字移至名字中 姓氏中

c++ - 如何通过 CPU 中的一个图在 tensorflow 中执行多个 session

c++ - 设置 GDB 硬件观察点/如何设置软件观察点