Open In App
Related Articles

Line Splicing in C/C++

Improve Article
Save Article
Like Article

While writing a program, sometimes we give comment about the working of the code in the comment section with the help of single/double comment line. But we had never thought that if at the end of this comment line if we use \(backslash) character then what will happen?
The answer of the above question is line Splicing. Lines terminated by a \ are spliced together with the next line very early in the process of translation. ยง2.2 Phases of translation
Actually whenever at the end of the comment line if we use \(backslash) character then it merges the immediate next line with current line which makes the new line also as a comment for the compiler. To avoid this issue multi-line comment can be used.


// C++ program to illustrate the concept of Line splicing.
#include <iostream>
using namespace std;
int main()
    // Line Splicing\
    cout << "Hello GFG\n";
    cout << "welcome\n";
    /*Example 2 - both of the below lines will be printed*/ \
    cout << "Hello\t";
    cout << "World";
    return 0;
// This code is contributed by sarajadhav12052009


// C program to illustrate the concept of Line splicing.
#include <stdio.h>
int main()
    // Line Splicing\
    printf("Hello GFG\n");
    /* Example 2 - both of the below lines will be printed*/ \
    return (0);


Hello    World

Explanation: In the above program as we can see when we use the \(backslash) character at the end of comment line. Then the next line of code is treated as comment in the program and the output is welcome. When we use multiline comment this issue get solved and both of the below lines of multiline comment will be printed.
If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 10 Jun, 2022
Like Article
Save Article
Similar Reads