LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-17-2012, 08:18 PM   #1
abcde597
Member
 
Registered: Oct 2012
Location: Alabama, US
Distribution: Several Debian Based Distros
Posts: 57

Rep: Reputation: Disabled
Question Can I get some help with a program in c? I'd like it to support "options".


I've been wondering, how do you handle extra "options" on a command line?
Ex: ls -v
Can I get an example in C also?
 
Old 10-17-2012, 09:57 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,774

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Take a look at the manpage for the getopt() library call. Note that what you need is the page in manual section 3 (i.e., "man 3 getopt), and if you just type "man getopt" you'll get the page for the getopt command (in section 1). There is also a manpage for the POSIX version of getopt() in section 3p. Since you posted in a Non-*NIX forum, it's hard to know which you might want.

There's a decent example at the end of the manpage.
 
Old 10-18-2012, 05:04 AM   #3
abcde597
Member
 
Registered: Oct 2012
Location: Alabama, US
Distribution: Several Debian Based Distros
Posts: 57

Original Poster
Rep: Reputation: Disabled
Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
"domain-name" and "host-name" options in dhcpd.conf m4rtin Linux - Server 3 09-20-2012 08:21 AM
Python "support" included in C program ITPhoenix Programming 2 07-11-2011 07:17 PM
Skip "Installation Method" and "Select Partition" screens using boot options tclappsdba Linux - Newbie 1 11-26-2010 05:31 AM
How do I disable "shutdown" and "restart" options in KDE logout screen for all users? maxgsp Linux - Distributions 1 12-12-2008 03:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration