View Full Version : Parsing command line options in C
WebDrake
June 26th, 2007, 07:40 PM
Can anyone recommend a C library to use for parsing command line options?
I imagine there are several out there so any comparison, discussion or general advice on the topic would be welcome.
Thanks in advance for any replies.
bunker
June 26th, 2007, 07:51 PM
getopt() (http://www.gnu.org/software/libc/manual/html_node/Getopt.html)
WebDrake
June 26th, 2007, 08:36 PM
getopt() (http://www.gnu.org/software/libc/manual/html_node/Getopt.html)
Looks great! Thank you very much. :)
moma
June 26th, 2007, 08:38 PM
Hello,
He is a small getopt() sample with short (-x) and long (--xxxx) options.
http://www.futuredesktop.org/tmp/getopt_test.c
Compile it:
$ gcc -Wall getopt_test.c -o getopt_test
Run it
$ ./getopt_test -h
$ ./getopt_test --help
$ ./getopt_test -u pekka --password=abc
---------
ps. I think the example is from "Advanced Linux Programming" book. It's freely available in pdf format.
Check this great resource: http://www.futuredesktop.org/opportunities.html The link is there.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.