Hi all
I am learning c and I did an exercise in a book. It doesn't seem to behave how expected if one of the command line arguments is an apostrophe.
Can someone help me?
Code:
#include <stdio.h>
int main(int argc, char *argv[])
{
int i = 0;
// go through each string in argv
for (i=1;i<argc;i++){
printf("arg %d: %s\n", i, argv[i]);
}
return 0;
}
Here are two different executions of the program (ex13). One with an apostrophe in the command line, another without. Can someone please tell me what is happening here?
With two words:
david@Parmenio:~/programming/c$ ./ex13 hello there
arg 1: hello
arg 2: there
With an apostrophe:
david@Parmenio:~/programming/c$ ./ex13 hello '
>
any ideas?
Dave.