Lesson 19 +10 XP

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

### World");

Output:


### Hello

### World

Other 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

### Quote: \"Not all those who wander are lost\"
");

Multiple newlines

Each `

` jumps one line, so two of them create a blank line:


c
printf("a

b");

Output: an empty line sits between a and b.

TL;DR

  • `

` starts a new line.

  • \t adds a tab.
  • \\ and \" let you print backslashes and quotes.
  • \0 is the null character that ends strings.