如何在C ++中拆分长行代码? [英] How to split long lines of code in c++?
本文介绍了如何在C ++中拆分长行代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要确保代码中的所有行都没有超过一定长度。
I need to make sure none of the lines in my code exceeds a a certain length.
通常,我将有逗号或其他合适的中断的行分开。
Normally I separate lines where there's a comma or another suitable break.
如何将这行分成2个?
cout<<"Error:This is a really long error message that exceeds the maximum permitted length.\n";
如果我只是在中间的某个位置按Enter键,则无效。
If I just press enter somewhere in the middle it doesn't work.
推荐答案
两个选项:
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 ++中拆分长行代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文