C++ Error - missing closing quote with \

backslash, c++, c-preprocessor, quote

Solution

You need to escape it. So either:

#define BACKSLASH '\\'

Or:

if((char)a.get() == '\\')
{
     // BLAH BLAH BLAH
}

Problem

I am using the `define` method in C++ with a backslash, in conjunction with an `ifstream`, which is called `a`. However, I get an error when using the backslash, which says: Error - missing closing quote. I have tried doing `#define BACKSLASH \`, but that contains no value at all: ``` #define BACKSLASH '\' if((char)a.get() == BACKSLASH // Error here) { // BLAH BLAH BLAH } ```

Original source