</code>
int main(int argc, char * argv[])
</code>
Can someone tell me why there is the need of asterick for char *argv[]. Does this make argv[] a pointer?
Printable View
</code>
int main(int argc, char * argv[])
</code>
Can someone tell me why there is the need of asterick for char *argv[]. Does this make argv[] a pointer?
argv is an array of char pointers, that's why there is an asterisk. Frankly speaking I myself doesn't know much about command line arguments, so other's reply will be more helpful.
argv[] is an array of pointers to string constants.
incorrect !
How informative it is... We can only try to guess what is so incorrect about it.
hahah...
I like GLSam's answer "How informative it is!", comment of a logical thinker.
argv[] ??? - NO
*argv[] <--- YES, this is what I meant :D
Just kidding ! NVM!
Basically, it can be written as **argv or *argv[] as argv[] is equivalent to *argv.
If *argv, it means that it takes a string.
If **argv, it means that it takes many strings. For example you create a programme called "scan". What you do here is to firstly type in the programme's name (scan) and followed by arguments/parameters when you are using the programme.
eg. scan -sP -PN 127.0.0.1
So, scan is the first string, -sP is the second string and so on. if you put *argv or argv[] only, it will only read one string (most likely scan).
int argc will tel you the position of the parameters. argc = 0 would be scan, argc = 1 would be -sP.
If you do not understand, please ask further.