Just avoid the slash as well as the quote! That is, \" → \\\"
fout << "std::string(\"-I\\\"/path/to/dir\\\" \");" << std::endl;
in C ++ 0x / C ++ 11
fout << R"(std::string("-I\"/path/to/dir\" ");)" << std::endl;
which uses a string literal 1
1 Why is it not surprising that syntax highlighting for ideone.com and stackoverflow have not yet been prepared :)
source share