.\" the start of optstring
.\" Modified 2006-12-15, mtk, Added getopt() example program.
.\"
-.TH GETOPT 3 2010-11-01 "GNU" "Linux Programmer's Manual"
+.TH GETOPT 3 2015-02-01 "GNU" "Linux Programmer's Manual"
.SH NAME
getopt, getopt_long, getopt_long_only,
optarg, optind, opterr, optopt \- Parse command-line options
If \fIflag\fP
is NULL, then
.BR getopt_long ()
-returns \fIval\fP. (For
-example, the calling program may set \fIval\fP to the equivalent short
+returns \fIval\fP.
+(For example, the calling program may set \fIval\fP to the equivalent short
option character.)
Otherwise,
.BR getopt_long ()
implementation (and probably all other implementations) implements the
correct behavior rather than that specified.
.SH EXAMPLE
+.SS getopt()
The following trivial example program uses
.BR getopt ()
to handle two program options:
}
}
- printf("flags=%d; tfnd=%d; optind=%d\\n", flags, tfnd, optind);
+ printf("flags=%d; tfnd=%d; nsecs=%d; optind=%d\\n",
+ flags, tfnd, nsecs, optind);
if (optind >= argc) {
fprintf(stderr, "Expected argument after options\\n");
exit(EXIT_SUCCESS);
}
.fi
-.PP
+.SS getopt_long()
The following example program illustrates the use of
.BR getopt_long ()
with most of its features.
}
.fi
.SH SEE ALSO
+.BR getopt (1),
.BR getsubopt (3)
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.