i see this alot, but i've never used it in a program, and i dont know whats it used for, so if someone can help me i'll be thankful
about int main (int argc, char **argv)
Page 1 of 17 Replies - 34844 Views - Last Post: 25 August 2008 - 02:43 PM
#1
about int main (int argc, char **argv)
Posted 22 August 2008 - 09:16 AM
hi guys,
i see this alot, but i've never used it in a program, and i dont know whats it used for, so if someone can help me i'll be thankful
i see this alot, but i've never used it in a program, and i dont know whats it used for, so if someone can help me i'll be thankful
Replies To: about int main (int argc, char **argv)
#2
Re: about int main (int argc, char **argv)
Posted 22 August 2008 - 09:22 AM
zerogee, on 22 Aug, 2008 - 09:16 AM, said:
hi guys,
i see this alot, but i've never used it in a program, and i dont know whats it used for, so if someone can help me i'll be thankful
i see this alot, but i've never used it in a program, and i dont know whats it used for, so if someone can help me i'll be thankful
The main() is in many ways, nothing more than a glorified function, and those are variables that can be passed from the command line into the actual program.
#7
Re: about int main (int argc, char **argv)
Posted 22 August 2008 - 11:07 AM
A little more detail to shed a bit more light on the subject:
Basically, they are parameters, which are passed to the program from another program~ most commonly, the system shell (cmd if you are on Windows)
main()
The entry point into any console application. As you delve into graphics development, you'll notice that it isn't always this. However, to keep things simple, let's just stick with main on its own.
int argc;
Stands for argument count. In other words, how many things are being passed into the program.
char **argv; or char *argv[];
Both do the exact same thing. Short for argument vector, or in other words, this is a multidimensional array that will store all arguments being passed to the function.
For a tutorial, click here.
Hope this helps
Basically, they are parameters, which are passed to the program from another program~ most commonly, the system shell (cmd if you are on Windows)
main()
The entry point into any console application. As you delve into graphics development, you'll notice that it isn't always this. However, to keep things simple, let's just stick with main on its own.
int argc;
Stands for argument count. In other words, how many things are being passed into the program.
char **argv; or char *argv[];
Both do the exact same thing. Short for argument vector, or in other words, this is a multidimensional array that will store all arguments being passed to the function.
For a tutorial, click here.
Hope this helps
#8
Re: about int main (int argc, char **argv)
Posted 25 August 2008 - 09:44 AM
Thanks for the info gabehabe. I had been wondering about this myself.
#9
Re: about int main (int argc, char **argv)
Posted 25 August 2008 - 01:14 PM
Wow, I think it was worth posting about that. I've been thanked twice for it today alone!
#10
Re: about int main (int argc, char **argv)
Posted 25 August 2008 - 01:26 PM
its either a pointer to a pointer of arguments or a pointer to an array of them, not necessarily multidimensional
#11
Re: about int main (int argc, char **argv)
Posted 25 August 2008 - 02:33 PM
But their behaviour simulates that of a multidimensional array, no matter how it is written. Correct?
#12
Re: about int main (int argc, char **argv)
Posted 25 August 2008 - 02:43 PM
not explicitly, otherwise it would be written as [][], however you can allocate any memory you want, so yes it could be multidimensional
especially since an array declared with a [] is simply a pointer to the first object (implicit conversion)
especially since an array declared with a [] is simply a pointer to the first object (implicit conversion)
Page 1 of 1

New Topic/Question
Reply



MultiQuote







|