Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Common C Escape Sequences

Part of the Beginning C Programming For Dummies Cheat Sheet

When you cannot type characters into your string, use the escape sequences to insert nonprintable characters into text strings, char variables, and arrays. Here are common C escape sequences:

Characters What It Represents or Displays
\a Bell ("beep!")
\b Backspace, non-erasing
\f Form feed or clear the screen
\n Newline
\r Carriage return
\t Tab
\v Vertical tab
\\ Backslash character
\? Question mark
\' Single quote
\" Double quote
\xnn Hexadecimal character code nn
\onn Octal character code nn
\nn Octal character code nn

Using escape sequences is the secret way to embed characters you cannot type into a string, or to test for those characters in a conditional statement or for regular input. Even printable characters can be coded by using an escape sequence. The \x hexadecimal and \nn sequences can represent any ASCII character.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus

SERIES
Beginning C Programming For Dummies Cheat Sheet

Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.