Loading lessons...
New Lines and Special Characters
New Lines and Special Characters
You've got text, now let's decide where lines break and add special characters with escape sequences.
The
newline
inside a string starts a new line:
C
printf("Hello\nWorld");Output:
Code
Hello
WorldOther useful escapes
\t- a tab (horizontal space)\\- a single backslash\"- a double quote inside a string\0- the null character (marks the end of a string)
Example
C
printf("Name:\tBilbo\nQuote: \"Not all those who wander are lost\"\n");Multiple newlines
Each jumps one line, so two of them create a blank line:
C
printf("a\n\nb");Output: an empty line sits between a and b.
TL;DR
- `
` starts a new line.
\tadds a tab.\\and\"let you print backslashes and quotes.\0is the null character that ends strings.