Sorry to ask so many questions, but what does char**, as in int main (int argc, char **argv), mean?
Sorry to ask so many questions, but what does char**, as in int main (int argc, char **argv), mean?
Well char** means a pointer to a pointer im not to sure what it means in that case though im sure someone here knows that part
Woop?
char * is the definition of a character string, and is the same as char[]. char ** is in effect a pointer to an array of strings, or char[][]. Basically the char ** stores the command line paramaters you give the program. So if you call for example ping 999.999.9.999 -s -a
you would have an argv of three (three arguments on the paramater list) and an argc** would be "999.999.9.999","-s","-a", strings that carry the actual paramaters.
Last edited by Draco; 08-09-2004 at 10:34 AM.
char[] and char * are not always the same. And passing a char[][] is not the same as char**.
As prog-bman stated char ** is a pointer to a pointer to a character.
When accepting an array you have a choice of syntax to use
(<type> *) or (<type> [])
Now when you load the program an array of pointers to characters is loaded for any arguments and main() can accept them. So you have a couple choices:
char *argv[] or char **argv
it might seem confusing but its just as above with the <type>. The type on this one is char *
OK cool. Thanks for the info - I don't know why I didn't see that. What is the difference, then, between using char* and using char[]? Is it that char* is dynamic and char[] is static?
it depends where you use it
In a function header or prototype there is no difference, the [] was put in for convience.
You would actually have an argc of 4 (an argument count of 4) along with an array of 4 character strings in argv:Originally Posted by Draco
argv[0]: ping
argv[1]: 999.999.9.999
argv[2]: -s
argv[3]: -a
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]