It is very nice that I can use the arguments passed to a program with the
but my question is how CAN i pass an argument to a program?Code:int main(int ArgC, char* Argv[])
(ok its newbie stuff, but I just dont know it)
Printable View
It is very nice that I can use the arguments passed to a program with the
but my question is how CAN i pass an argument to a program?Code:int main(int ArgC, char* Argv[])
(ok its newbie stuff, but I just dont know it)
Start the program from the console using:
MyProg 45 2 987
or something
Oh, and another useful aspect of main arguments: If you associate (sp?) a file extension with your program, then double click on that file, your program will load with the path + filename of that file as an argument.
This is really useful, since you can tell your program to automatically load this file.
Small example, note that the first arg is the programs name.
Code:#include <stdio.h>
int main(int ArgC, char* Argv[])
{
for(int i=0; i< ArgC; i++)
printf("Argv %d = %s\n", i, Argv[i]);
return 0;
}