Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The GNU C Programming Tutorial - Special characters

Node:Special characters, Next:, 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.

 
 
  Published under free license. Design by Interspire