C Command-line parameters?

kevkid

Baseband Member
Messages
31
I am a bit confused as to how to implement this, I have looked online and am not understanding it much if anyone can clear this up for me. I always thought it was simply just a switch statement with the '-' trimmed. If anyone can please help It would be greatly appreciated.

Thanks

Kevin
 

strollin

Knowitall!
Messages
3,565
Location
N. Calif.
Command line parameters in a C program are passed in via the argv array, and an additional parameter, argc, which contains the count of the items in the array.

A C program invoked such as " test a b c" will have an argc count of 4 and the argv array will look like:

argv[0] = test
argv[1] = a
argv[2] = b
argv[3] = c

For a more complete answer see: http://www.crasseux.com/books/ctutorial/argc-and-argv.html
 
Last edited:
Top