Node:Special characters, Next:Character conversion table, Previous:Precedence of operators, Up:Top
Special characters
Control characters are invisible on the screen. They have special purposes usually to do with cursor movement and are written into an ordinary string or character by typing a backslash character \ followed by some other character. These characters are listed below.
A character can be any ASCII character, printable or not printable
from values -128 to 127. (But only 0 to 127 are used.) Control
characters i.e. non printable characters are put into programs by
using a backslash \
and a special character or number. The characters
and their meanings are:
\b
- backspace BS
\f
- form feed FF (also clear screen)
\n
- new line NL (like pressing return)
\r
- carriage return CR (cursor to start of line)
\t
- horizontal tab HT
\v
- vertical tab (not all versions)
\x
- ???
\"
- double quotes (not all versions)
\'
- single quote character '
\\
- backslash character \
\ddd
- character ddd where ddd is an ASCII code given in octal or base 8. (See Appendix C)
Here is a code example that prints special characters:
/***************************************************/ /* */ /* Special Characters */ /* */ /***************************************************/ #include <stdio.h> main () { printf ("Beep! \7 \n"); printf ("ch = \'a\' \n"); printf (" <- Start of this line!! \r"); }
The output of this program is:
Beep! (and the BELL sound) ch = 'a' <- Start of this line!!
and the text cursor is left where the arrow points.