I understand that command line arguments are pointed by the string pointers in the argv [] array. i.e. argv [0] contains a pointer to the name of the program and argv [1] a pointer to the very first command line argument.
But I noticed a very different application of argv on the internet and is written below. I have compiled it successfully and it print out the second arguments third character.
#include <stdio.h>
int main(int argc , char *argv []) {
printf("%c\n", argv [1][2]);
return 0; }
I have two question arising from this use.
What is the true dimension of argv? does it stop at two or is there more?
I have noticed it the code that the programer has used %c to access and print the pointed content. Now, we can always parse a pointer (a string pointer) to %s and expect it to print out the set of chars untill null terminator.
upto the best of my understanding %c can only be used if the array it self contains the character.
i.e.
char yadhavan [] = yadhavan is a boy;
printf ("%c", yadhavan [3]);
Could someone please explain how %c has been used with a pointer array?
A little more explanation is always more than welcome!