jeudi 1 juin 2017

Can you combine the raw string literal modifier R"()" with a string contained within a variable?

Example

For example:

string MyString = "Normal\tString";
cout << MyString << endl;

produces the following: "Normal String"


Appending the raw string modifier to the string like so:

string MyString = R"(Normal\tString)";
cout << MyString << endl;

produces the following: "Normal\tString"


The Question

Is there a way to append the raw string modifier to a variable containing a string in order to print the raw form of the string contained within the variable?

string TestString = "Test\tString";
cout << R(TestString) << endl;

So you get: "Test\tString"

Aucun commentaire:

Enregistrer un commentaire