The function main can be called with two arguments. The first (conventionally called argc, for argument count) is the number of command-line arguments the program was invoked with; the second (argv, for argument vector) is a pointer to an array of character strings that contains arguments, one per string.
By convention argv[0] is the name by which the program was invoked, so argc is atleast one.
So
argv is a pointer to an array of pointers
argv[i] or *(argv + i) is a character pointer that points to the first character of the i+1 th command line argument.
and *argv[i] is the charcter it points to
Let us say you invoke a program "program" like this :
Code:
koodoo@knapsacker:~$ ./program sachitha such indee
Code:
argv--------------->| argv[0] |-------> ./program
| argv[1] |-------> sachitha
| argv[2] |-------> such
| argv[3] |-------> indee
| 0 |
So
argv[1] points to s in sachitha and printf("%s", argv[i]) would print sachitha. If you do argv[1]++, argv[1] will now point to a in sachitha and the string output would now be achitha.
Note however the difference between the
prefix and postfix notations of the ++ operator.
printf("%s", ++argv[i]) : argv[1] points to a in sachitha and achitha gets printed while in,
printf("%s", argv[i]++) : argv[1] points to a in sachitha and sachitha gets printed
Now argv[1][3] is the (3 + 1)th character in the string pointed to by argv[1]. Note argv[1][3] is the actual character and not a pointer to char
So initially argv[1] points to s in sachitha and argv[1][3] is h. If we do argv[1]++ then argv[1] points to a in achitha and argv[1][3] is i.
I do not know anything about perl so I cannot answer your second querry.
Hope this helps.