BETA Try the new lesson view
Code

Special characters

Some characters cannot simply go inside the quotes: " would end the string, and \ and % have a special meaning. You write them like this:

You write You get
\n a new line
\t a tab: a jump to the next column, every 8 characters
\" a quote "
\\ one \
%% one % (only in a printf string)

\ starts an escape sequence: together with the next character it means one character. % starts a printf format: in topic 2, %d will put a number there. That is why a real % needs two.

At the end of the program, before return 0;, add a small table, a path and a percentage:

    printf("\n");
    printf("Grade\tMeaning\n");
    printf("10\t\"excellent\"\n");
    printf("5\t\"satisfactory\"\n");
    printf("File: C:\\course\\practice\\01\\main.c\n");
    printf("Done: 100%%\n");

Run it. The last lines:

Grade	Meaning
10	"excellent"
5	"satisfactory"
File: C:\course\practice\01\main.c
Done: 100%

The tab lines up the columns: 10 and Grade both end before column 8, so the second column starts at the same place.

Make a commit: Print special characters.

Two errors you will see

In the path, write one \ instead of \\ (C:\course):

C:/.../practice/01/main.c:15:53: error: unknown escape sequence: '\c' [-Werror]
   15 |     printf("File: C:\course\\practice\\01\\main.c\n");
      |                                                     ^

\c is not an escape sequence. But C:\new would give no error: \n is a new line, and the output would show C: and then ew on the next line.

Write 100% instead of 100%%:

C:/.../practice/01/main.c:16:23: error: unknown conversion type character '\x0a' in format [-Werror=format=]
   16 |     printf("Done: 100%\n");
      |                       ^~

printf thinks % starts a format, and what follows is a new line ('\x0a' is the code of \n). There is no such format.

Put both places back as they were.