C++ char type Escape Sequences That Represent Control Characters

Introduction

Escape Sequence Control Character
\nNewline
\tHorizontal tab
\vVertical tab
\bBackspace
\rCarriage return
\fForm feed
\aAlert/bell
\\ Backslash
\' Single quote
\" Double quote
\? Question mark

Because the backslash signals the start of an escape sequence, to enter a backslash, use two successive backslashes \\.

The following code that uses escape sequences outputs a message to the screen.

#include <iostream>

int main()/*from w  w  w.  j a  va 2 s. c o m*/
{
  std::cout << "\"Least \'said\' \\\n\t\tsoonest \'mended\'.\"" << std::endl;
}



PreviousNext

Related