C & C++

C & C++

Made by DeepSource

Found use of escape character instead of raw-string literals CXX-W2025

Anti-pattern
Minor
Autofix

Raw string literals are used in C++ to avoid using escape characters. They can be used to express all types of string literals. A raw string literal enables you to express a string without having to perform extra construction or conversion steps.

For example, if you want to express a string that contains a backslash, you can use a raw string literal to avoid having to escape the backslash.

Bad practice

const char* const src = "this is a \"string\"";
const std::string str = "This is a string with a backslash: \\";

Recommended

const char* const src = R"lit(this is a "string")lit";
const std::string str = R"(This is a string with a backslash: \)";