Click here to Skip to main content
15,566,065 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi So I saw on this tutorial that a string literal was spanning over 2 lines and it was working correctly but there was a "/" symbol. I dont understand the logic behind this. Can you give some examples of this multiple line string literals so I understand them?

"hello, \


From link: C - Constants and Literals - Tutorialspoint[^]

What I have tried:

I have not tried anything because it just does not seem to be logical.
Updated 3-Jan-21 11:56am

The use of a backslash seems to date back to the days when punch cards were used:
Making the number of spaces at the end of a line be
signifigant means you can't represent your programs on punch cards, or
other fixed-line-length file formats
Re: Preprocessor Problem?[^]

If you don't use punch cards you could use something like this:
#include <stdio.h>

int main() {

   ", dear");

   return 0;
Share this answer
One small point to add - the backslash, '\', is often an escape character. It tells the compiler to translate the following character. There are several standard escape sequences: '\r' is a return, '\n' is a newline, '\t' is a tab, '\0' is a null, and '\' at the end of a line means continue the previous line or ignore the line break. To use a backslash literally as a character or in a string it has to be escaped so you will see the infamous double backwhack: '\\'.
Share this answer
Okey the solution: Its just a "\" symbol when the line is finished and the string should continue on the next line.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900