Check if character equals in C++

Check if character equals in C++

Backslash is used as the escape character in C++, as it is in many other languages. If you want a literal backslash, you need to use \:

if (c == \) {

}

backslash is an escape character.

Escape sequences are used to represent certain special characters
within string literals and character literals.
Read here

So you should do:

if (c == \){
}

Check if character equals in C++

You need escape sequences:

\    backslash   byte 0x5c in ASCII encoding 

Change the code to

if (c == \)

Leave a Reply

Your email address will not be published. Required fields are marked *