Archived

This topic is now archived and is closed to further replies.

Xnin

Simple Question.

Recommended Posts

Xnin    122
hi What does the "int argc, char** argv" mean when they are uesd in the main function? For example:
void main ( int argc, char** argv )  
{
  glutInit            ( &argc, argv );

-
}

 
Then the address of argc is past on to the glutinit function with the "argv" pointer. Why do we have to do that? Thanks for any help.

Share this post


Link to post
Share on other sites
Nemesis2k2    1045
Those are related to the command line arguments. Eg, "program.exe /d". It''s been awhile, but I believe argc is the number of parameters passed, and argv is a character array of the parameters. Check some C++ tuts for info on that.

Share this post


Link to post
Share on other sites
K-1    122
Yes that is correct. "argc" is the number of tokens specified on the command line. And "argv" is an array of char * to the tokens.

Using the example given by Nemesis2k2:

argc = 2
argv = {"program.exe", "/d"}

Since glut is C driven (I believe), you need to pass in pointers to objects instead of passing by reference (as you would in C++)

Share this post


Link to post
Share on other sites