Hi everyone, can somebody tell me what the parameters "int argc and char* argv[]" are for in the main() function. I've came across this many times and i still don't know what these two parameters do.
This is when the SO calls your program it sends arguments like a function.
In Windows the first argument it's always the path of program with his name. When you call the program througth line command you can put more arguments like the DOS commands dir / find / cd / etc...
From a game programming point of view, it makes it easier to do things in your code so that if you want to test something but not worry about health or ammo or such you can pass arguments in the command line and set it so you have permanent health/ammo/etc while testing what you wanted to test.
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
int main(int argc, char **argv)
{
for(int i = 0; i < argc; i++)
{
std::cout << argv[i] << '\n';
}
return 0;
}
./commargs completely helpful in programming apps and debugging :D
./commargs
completely
helpful
in
programming
apps
and
debugging
:D