Good day people!
The context is resize program in problem set 4, however, the question is general.
Following is how the main function begins for the relevant program: int main(int argc, char *argv[])
Following is how you run the same relevant program: ./resize 22 help.c me.c
The main function takes in command line arguments and stores them with char *argv[]. char *argv[] is an array that will store character pointer variables, each of which will point to the first character of one of the command line arguments entered when running the program.
You have 'argv' (array name) which is a pointer constant pointing to the first RAM address corresponding to the first byte of the contiguous block of RAM made use of for storing the character pointer variables that will each point to the first character (by memory address) of one of the command line arguments entered when running the program.
I am confused at how to access each of the [system null terminated] strings entered as command line arguments i.e. ./resize\0 22\0 help.c\0 me.c\0
Per my understanding, I would have thought that to access any of the stored and null terminated strings, you would have to 'double dereference'.
E.g. argv[0] is the same as *(argv + 0) which would take us to a RAM address that is the RAM address of a character pointer variable, itself storing another RAM address that would take you to the first character of ./resize\0
So to get to the first character of ./resize\0, you would have to double dereference e.g. *(argv[0]) or **(argv + 0) - but from all that I have seen, argv[0] alone is sufficient to take you all the way to the first character of ./resize\0
PLEASE can someone explain to me what I am missing?