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

How to pass in "&" as the input argument to a program?

P: n/a
I call my program like this:

$ ./test http://myserver.com/get?id=XaXz-dryq...wpxDB64juPIhQR

But only this get printed out:
./test
http://myserver.com/get?id=XaXz-dryqLg

It seems like the second 'argv' get chopped off at '&' , can you
please tell me why is that and how to fix it?

int main( int i_argc, char *argv[] )
{

fprintf (stderr, "******************\n");
for (int i = 0; i < i_argc; i++) {
fprintf (stderr, " %s\n",argv[i]);
}

//....
}

Jun 2 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
yi*****@gmail.com wrote:
I call my program like this:

$ ./test http://myserver.com/get?id=XaXz-dryq...wpxDB64juPIhQR

But only this get printed out:
./test
http://myserver.com/get?id=XaXz-dryqLg

It seems like the second 'argv' get chopped off at '&' , can you
please tell me why is that and how to fix it?
The problem is with your shell (it is interpreting the '&'), not your
program. Try quoting the input string.

--
Ian Collins.
Jun 2 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.