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
[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,
In the morning when looking at the source project Webbench, just at the beginning was a seemingly strange function getopt_long () to get stuck, to tell the truth this function has not seen, naturally do not know what this buddy is doing. So Baidu,
The parameter options under the command-line tool are available in two, long and short options . The short option starts with--a single letter followed by a long option--to start with, followed by multiple letters. I. getopt ()1. Function : Parse
Recently done cache lab used the getopt function, with man 3 getopt view the following usage, make a summary.
Description: The Getopt function is used to parse command-line arguments, with an option element of '-' or '-' that starts with a '-' or '-
1. Main function Parameter formint Main (int.Char char *env[]); // the first parameter, ARGC, represents the number of arguments on a command line // The second parameter points to each parameter in turn, such as "Ls-l", argv[0] to "LS", argv[1] to "
Transferred from: https://www.cnblogs.com/qingergege/p/5914218.htmlRecently in the Linux C programming, undergraduate time did not study well, hope to learn younger brothers learn lesson.Well, it's a bit verbose, but it's really a piece of advice.
This article is one of the book notes in Chapter 6 "learning the bash shell" 3rd edition "command-line options and typed varilables, but we will not limit this article.
In Linux commands, parameters such as [-Option] are often included. There may be
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 excerpt from: https://www.cnblogs.com/qingergege/p/5914218.htmlFunction One:int getopt (int argc, char* argv[], const char* optstring);Parameters 1, 2 are the input parameters of the main function, parameter 3 is the option string, and
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.