Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 06-01-2012, 12:44 PM   #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.

Thanks

Kevin
__________________

kevkid is offline   Reply With Quote
Old 06-01-2012, 08:25 PM   #2
Fully Optimized
 
strollin's Avatar
 
Join Date: Mar 2011
Location: USA
Posts: 1,944
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
Reply

Tags
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 08:33 PM.


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