![](http://www.crosswinds.net/~druidgames/resist.jpg)
need help with (int argc, char *argv[])
Greetings all, I need assistance on using argc, argv. I have books with them in it but they don''t describe the concept behind them. Any help is appreciated. Thanks.
-----------------------------
"There are ones that say they can and there are those who actually do."
"...u can not learn programming in a class, you have to learn it on your own."
![](http://www.crosswinds.net/~druidgames/resist.jpg)
-----------------------------"There are ones that say they can and there are those who actually do.""...u can not learn programming in a class, you have to learn it on your own."
These are used for programs that are run from the comand line. Each argument can take a value which can be used withing the program. (like those old dos programs) they can also be used when running the program from withing another program. (i think)
HHSDrum@yahoo.com
HHSDrum@yahoo.com
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
argc is the number of command line arguements passed to your program. argv are the actual arguements.
Here''s an example
argv[0] is the program itself, so your args start at 1.
Here''s an example
|
argv[0] is the program itself, so your args start at 1.
void main(int argc, char *argv[])
{
if (argc == 1)
{
printf("usage: bla.exe");
return;
}
if (argc == 2)
{
// do something with argv[1],
// argv[0] is your executable file name
}
else
{
printf("too many arguments");
return;
}
}
pretty easy
you get the string parsed already which make it easier
Arkon
[QSoft Systems]
{
if (argc == 1)
{
printf("usage: bla.exe
return;
}
if (argc == 2)
{
// do something with argv[1],
// argv[0] is your executable file name
}
else
{
printf("too many arguments");
return;
}
}
pretty easy
you get the string parsed already which make it easier
Arkon
[QSoft Systems]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement