Go Back   Computer Forums > General Computing > Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 06-01-2012, 11:44 AM   #1
Baseband Member
Join Date: Sep 2006
Posts: 31
Question C Command-line parameters?

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.



kevkid is offline   Reply With Quote
Old 06-01-2012, 07:25 PM   #2
Fully Optimized
strollin's Avatar
Join Date: Mar 2011
Location: USA
Posts: 1,584
Default Re: C Command-line parameters?

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/ctutor...-and-argv.html
strollin is offline   Reply With Quote

c language, command, command-line parameters

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 01:22 AM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0