By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,412 Members | 1,007 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,412 IT Pros & Developers. It's quick & easy.

quoting quotes, &c.

P: n/a
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\"; ' ");

? are there other ways?

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.