Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > How to pass in "&" as the input argument to a program?

Reply
Thread Tools

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

 
 
yinglcs@gmail.com
Guest
Posts: n/a
 
      06-02-2007
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]);
}

//....
}

 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      06-02-2007
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: Variable Input on procedure - pass by value or pass by reference? Reuven VHDL 0 03-19-2009 07:21 PM
Re: Variable Input on procedure - pass by value or pass by reference? Tricky VHDL 0 03-19-2009 03:59 PM
Variable Input on procedure - pass by value or pass by reference? Tricky VHDL 0 03-19-2009 03:58 PM
How to pass variable argument list to another function w/ variable argument list? Ben Kial C Programming 1 11-15-2004 01:51 AM



Advertisments