C Programming Absolute Beginner's Guide (3rd Edition)

(Romina) #1
Note

The string You are on your way to C mastery is the controlString
in this printf(). There is little control going on here—just output.

The following two printf() statements might not produce the output you expect:


printf("Write code");
printf("Learn C");

Here is what the two printf() statements produce:


Write codeLearn C

Tip

C does not automatically move the cursor down to the next line when a printf()
executes. You must insert an escape sequence in the controlString if you want C
to go to the next line after a printf().

Escape Sequences


C contains a lot of escape sequences, and you’ll use some of them in almost every program you write.
Table 4.1 contains a list of some of the more popular escape sequences.


TABLE 4.1 Escape Sequences

Note

The term escape sequence sounds harder than it really is. An escape sequence is
stored as a single character in C and produces the effect described in Table 4.1. When
C sends '\a' to the screen, for example, the computer’s bell sounds instead of the
Free download pdf