- [Tutor] Some characters in C plus plus
have special meaning
or otherwise not normally accessible
within the parameters of the C plus plus language.
Escape sequences are used to access these characters.
This is working dot cpp
from chapter three of the exercise files.
Each escape character begins with a backslash character.
And if you need to type the actual backslash character
then you use a double backslash result
in a single backslash.
So I'll go ahead and build and run this
and you can see that it displays, hello world.
And if I want to add a single quote,
I use backslash single quote,
I use backslash double quote to get a double quote.
I use two backslashes to get a backslash
or backslash x four zero.
I can access any character in the ASCII table
by giving its hexadecimal value beginning with an x.
And so this will be the at sign,
and if I go ahead and build and run here,
you see, I get that single quote, double quote backslash
and the at sign.
If I want to get a new line,
I can use backslash n,
and if I want to get a tab, I can use backslash t
and if I go ahead and build and run this
you see, we have a new line and a tab.
So world is starting indented there on a line by itself.
You can get any character in the Unicode table
on a system that supports Unicode.
I can say, u zero three bc
and this will give me a Greek letter mu
on systems that support this.
So when I build and run
you'll see the Greek letter mu there.
Notably Microsoft Visual C plus plus
does not support Unicode by default,
at least as of the time that I'm recording this.
So your results here may vary.
So this is a table
of the most common standard character escape sequences.
You can find a table like this online, pretty much anywhere.
Character escape sequences
are commonly used to provide special characters
in the string constants
that may not otherwise be accessible on the keyboard
or due to conflicts in the language.