I need to do the following C# code in C++ (if possible). I have to const a long string with lots of freaking quotes and other stuff in it.
const String _literal = @"I can use "quotes" inside here";
That is not available in C++03 (the current standard).
That is part of the C++0x draft standard but that's not readily available just yet.
For now, you just have to quote it explicitly:
const std::string _literal = "I have to escape my quotes in \"C++03\"";
Once C++0x becomes reality, you'll be able to write:
const std::string _literal = R"(but "C++0x" has raw string literals)";
and when you need )"
in your literal:
const std::string _literal = R"DELIM(more "(raw string)" fun)DELIM";
There is no equivalent of C#'s "@" in C++. The only way to achieve it is to escape the string properly:
const char *_literal = "I can use \"quotes\" inside here";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With