September 1998
Intermediate to advanced
848 pages
20h 13m
English
Let's run one more printing example, one that makes use of some of C's special escape characters. In particular, the program in Listing 3.9 shows how backspace (\b), tab (\t), and carriage return (\r) work. These concepts date from when computers used teletype machines for output and they don't always translate successfully to contemporary graphical interfaces. For example, this listing doesn't work as described on some Macintosh implementations.
/* escape.c--uses escape characters */ #include <stdio.h> int main(void) { float salary; printf("Enter your desired monthly salary:"); /* 1 */ printf(" $_______\b\b\b\b\b\b\b"); /* 2 */ scanf("%f", &salary); printf("\n\t$%.2f a month is $%.2f a year.", ... |
Read now
Unlock full access