In Linux, many programs, even those with graphical user interfaces (guis), can accept and process command line options. For some programs, this is the main means to interact with other programs or users. With a reliable and complex command line
Reprinted -- Use of the getopt Function The author writes well.Every day you are using a large number of command line programs. Do you feel that the command line parameters are easy to use? They are all implemented using getopt.Using getopt to write
Http://apps.hi.baidu.com/share/detail/17204074
Getopt is used to parse command line option parameters. You don't have to write your own stuff to process argv.
# Include Extern char * optarg; // parameter pointer of the optionExtern int optind, //
This article based on http://jesserei.blog.163.com/blog/static/121411689200983081421390/, slightly modified
Generally, various commands in Linux have many command line parameters to choose from, such:Gcc-g-LM Foo. C-o fooGetopt () is a function used
[Reprint] The getopt () function and its parameters optind and getoptoptind
Recently, the getopt () function has been used to understand it. This blog post is still very clear. It is worth learning. Recently, an open-source project has been improved,
Getopt is used to parse command line option parameters.
# Include Extern char * optarg; // parameter pointer of the optionExtern int optind, // when getopt is called next time, check the option again from the position where optind is stored.Extern
How to analyze the command line parameters sun,-marchday
There are two types of command line options in GNU/Linux: short option and long option. The former uses '-' as the leading character, and the latter uses '--' as the leading character.. For
/*************************************** ******************************
* Function: Test getopt* Author: Samson* Date: 11/30/2011* Test Platform:* GNU Linux version 2.6.29.4* GCC version 4.4.0 20090506 (Red Hat 4.4.0-4) (GCC)*************************
# Include
Int getopt (INT argc, char * const argv [], const char * optstring );
Extern char * optarg;
Extern int optind, opterr, optopt;
Description:
The getopt () function parses the command line parameters. The first two parameters -- argc
The getopt () function is used to analyze command line parameters. Its function prototype and related variables are declared as follows:
# IncludeExtern char * optarg;Extern int optind, // The initialization value is 1. When getopt is called next
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.