Line Splicing in C/C++


In this section we will see what is the line spacing in C or C++. Sometimes we put some single line comment using double slash “//”. The one-line comment is basically ends when we move to the next line. But if we put back slash at the end of some single line comment, then what will be the effect?

When back slash is used it continues to the next lie. So after the comment line, if there are some line after comment, it will also be ignored. Let us see an example.

Example

 Live Demo

#include <iostream>
using namespace std;
int main () {
   //This is a comment line ending with back slash\
   cout << "Line after comment" << endl;
   cout << "Next line";
}

Output

Next line

In this situation we have to put one extra line space between comment line and the next line of code. Please see the difference between the previous code and the next code.

Example

 Live Demo

#include <iostream>
using namespace std;
int main () {
   //This is a comment line ending with back slash\
   cout << "Line after comment" << endl;
   cout << "Next line";
}

Output

Line after comment
Next line

Updated on: 30-Jul-2019

316 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements