C/C++ 中的行拼接
在本节中,我们将了解 C 或 C++ 中的行间距。有时我们使用双斜杠“//”来添加一些单行注释。单行注释基本上在转到下一行时结束。但是,如果我们在一些单行注释的末尾加上反斜杠,那么会产生什么影响?
当使用反斜杠时,它将继续到下一行。因此,在注释行之后,如果注释后面有几行,也会被忽略。让我们来看一个例子。
示例
#include <iostream>
using namespace std;
int main () {
//This is a comment line ending with back slash\
cout << "Line after comment" << endl;
cout << "Next line";
}输出
Next line
在这种情况下,我们必须在注释行和下一行代码之间留一行额外的空白。请查看之前的代码和下一段代码之间的差异。
示例
#include <iostream>
using namespace std;
int main () {
//This is a comment line ending with back slash\
cout << "Line after comment" << endl;
cout << "Next line";
}输出
Line after comment Next line
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP