see i have below code
#include<stdio.h>
int main ( int argc, char *argv[] )
{
int i=0;
for(i=1;i<argc-1;i++)
printf(" %s \n",argv[i]);
return 0;
}
compiles and run as follows
gcc test.c
./a.out 1 * 2
and now its o/p is scarred..!
o/p is :
1
a.out
Desktop
Documents
Downloads
ipmsg.log
linux-fusion-3.2.6
Music
Pictures
Public
Templates
test.c
You could invoke your test using
if you want to pass * as an argument. You can also use single quotes
'*'(as suggested by Esa) or double quotes"*".Note also that your loop currently ignores the last argument. Use
i<argcas your exit condition if this isn’t deliberate.