I need to compare variable value with backslash symbol:
char symbol;
/* assigning a value to
a variable */
if (symbol == '\') {
// some action
}
But my Visual Studio recognizes it as a character constant. How can I ignore it?
Maybe there is a "r" prefix like in python:
symbol = r'\'
>Solution :
You can use double slashes (\\) or use raw string literals to avoid escaping backslashes.
char symbol;
if (symbol == '\\') {
// some action
}
or
char symbol;
if (symbol == R"\") {
// some action
}