When trying to create a string literal

  "C: \" 
the closing quote is escaped, which must be avoided.

  • four
    And you reverse the slash, then the quote will not be escaped. - Visman
  • 3
    "C:\\" - that's it. '\\' is a backslash character. - andy.37

2 answers 2

you escape quotes, but you need to escape slash. Replace so

  "C:\\" 

or

  "C:/" 

    There is also a variant of using raw string literals ( C++11 ) to exclude escapes:

     #include <iostream> int main() { const char* s = R"(C:\)"; std::cout << s << "\n"; } 

    C: \

    Test

    • one
      fucking json in them is convenient to cram in for tests - strangeqargo
    • one
      @strangeqargo and more. - αλεχολυτ