Try the following:
Code:
#include <stdio.h>
int main(int argc, char *argv[])
{
int i;
printf("\\Number of command line arguments = %d\n\n", argc);
for (i = 0; i < argc; i++) {
printf("Arg %d: <%s>\n", i, argv[i]);
}
printf("Press 'Enter' to exit the program (anyone see the irony here?) ");
getchar(); /* this is necessary if you invoke by clicking; otherwise
* the window will not remain open after the information
* is printed out */
return 0;
}
Invoke this from a "DOS" window, and try different command line arguments.
What happens in each case:
printargs
printargs 1 2 3
printargs "This is a string" /option 1
(Now you try some with your arguments.)
Have fun!
Dave