jsnX wrote:
if i wanted to call system with an argument to a function that had
double quotes and backslashes in it - for example
perl -e 'print "hello world\n"; '
how would i make that work? would it be:
std::system("perl -e 'print \"hello world\\n\"; ' ");
?
Does it work for you? If it does, why ask "would it be"? If it does
not, what happens?
'system' function accepts a string that is passed in an implementation-
defined way to the host platform. Nothing beyond that is specified.
To add a backslash to a string literal, you need to double it. To add
a double quote, you need to escape it with a backslash.
are there other ways?
Yes, there are probably other ways, platform-specific, no doubt. In what
sense "other"? A different way to represent double quotes? Yes, you can
use the \xHH notation where HH is the value in the host character set,
representing the double quotation character, and you can use the same for
the backslash... Is that what you're asking for?
V