jeudi 17 août 2017

Is there a way to write a C++ string literal without having to escape every quote (") or other special character?

I want to put this

<script src = "Script2.js" type = "text/javascript"> < / script>"

in a C++ string so I apped a (\) symbol before every double quotes (") to give it a literal meaning of ", instead of a string demarcation in C++.

like this:

std::string jsFilesImport = "<script src = \"Script2.js\" type = \"text/javascript\"> < / script>\""

If i have a big string with many ("- double quotes) adding (\) for every (") becomes difficult. Is there a simple way in C++ to achieve this ?

Aucun commentaire:

Enregistrer un commentaire