亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? library_22.html

?? linux_c函數,linux下編程必備的
?? HTML
?? 第 1 頁 / 共 3 頁
字號:
<!-- This HTML file has been created by texi2html 1.27
     from library.texinfo on 3 March 1994 -->

<TITLE>The GNU C Library - Process Startup and Termination</TITLE>
<P>Go to the <A HREF="library_21.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html">previous</A>, <A HREF="library_23.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html">next</A> section.<P>
<H1><A NAME="SEC385" HREF="library_toc.html#SEC385" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC385">Process Startup and Termination</A></H1>
<A NAME="IDX1622"></A>
<P>
<DFN>Processes</DFN> are the primitive units for allocation of system
resources.  Each process has its own address space and (usually) one
thread of control.  A process executes a program; you can have multiple
processes executing the same program, but each process has its own copy
of the program within its own address space and executes it
independently of the other copies.
<P>
This chapter explains what your program should do to handle the startup
of a process, to terminate its process, and to receive information
(arguments and the environment) from the parent process.
<P>
<A NAME="IDX1623"></A>
<A NAME="IDX1624"></A>
<H2><A NAME="SEC386" HREF="library_toc.html#SEC386" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC386">Program Arguments</A></H2>
<A NAME="IDX1625"></A>
<P>
The system starts a C program by calling the function <CODE>main</CODE>.  It
is up to you to write a function named <CODE>main</CODE>---otherwise, you
won't even be able to link your program without errors.
<P>
You can define <CODE>main</CODE> either to take no arguments, or to take two
arguments that represent the command line arguments to the program, like
this:
<P>
<PRE>
int main (int <VAR>argc</VAR>, char *<VAR>argv</VAR>[])
</PRE>
<A NAME="IDX1626"></A>
<A NAME="IDX1627"></A>
<P>
The command line arguments are the whitespace-separated tokens given in
the shell command used to invoke the program; thus, in <SAMP>`cat foo
bar'</SAMP>, the arguments are <SAMP>`foo'</SAMP> and <SAMP>`bar'</SAMP>.  The only way a
program can look at its command line arguments is via the arguments of
<CODE>main</CODE>.  If <CODE>main</CODE> doesn't take arguments, then you cannot get
at the command line.
<P>
The value of the <VAR>argc</VAR> argument is the number of command line
arguments.  The <VAR>argv</VAR> argument is a vector of C strings; its
elements are the individual command line argument strings.  The file
name of the program being run is also included in the vector as the
first element; the value of <VAR>argc</VAR> counts this element.  A null
pointer always follows the last element: <CODE><VAR>argv</VAR>[<VAR>argc</VAR>]</CODE>
is this null pointer.
<P>
For the command <SAMP>`cat foo bar'</SAMP>, <VAR>argc</VAR> is 3 and <VAR>argv</VAR> has
three elements, <CODE>"cat"</CODE>, <CODE>"foo"</CODE> and <CODE>"bar"</CODE>.
<P>
If the syntax for the command line arguments to your program is simple
enough, you can simply pick the arguments off from <VAR>argv</VAR> by hand.
But unless your program takes a fixed number of arguments, or all of the
arguments are interpreted in the same way (as file names, for example),
you are usually better off using <CODE>getopt</CODE> to do the parsing.
<P>
<A NAME="IDX1628"></A>
<A NAME="IDX1629"></A>
<A NAME="IDX1630"></A>
<H3><A NAME="SEC387" HREF="library_toc.html#SEC387" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC387">Program Argument Syntax Conventions</A></H3>
<P>
POSIX recommends these conventions for command line arguments.
<CODE>getopt</CODE> (see section <A HREF="library_22.html#SEC388" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_22.html#SEC388">Parsing Program Options</A>) makes it easy to implement them.
<P>
<UL>
<LI>
Arguments are options if they begin with a hyphen delimiter (<SAMP>`-'</SAMP>).
<P>
<LI>
Multiple options may follow a hyphen delimiter in a single token if
the options do not take arguments.  Thus, <SAMP>`-abc'</SAMP> is equivalent to
<SAMP>`-a -b -c'</SAMP>.
<P>
<LI>
Option names are single alphanumeric characters (as for <CODE>isalnum</CODE>;
see section <A HREF="library_4.html#SEC55" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_4.html#SEC55">Classification of Characters</A>).
<P>
<LI>
Certain options require an argument.  For example, the <SAMP>`-o'</SAMP> command
of the <CODE>ld</CODE> command requires an argument--an output file name.
<P>
<LI>
An option and its argument may or may not appear as separate tokens.  (In
other words, the whitespace separating them is optional.)  Thus,
<SAMP>`-o foo'</SAMP> and <SAMP>`-ofoo'</SAMP> are equivalent.
<P>
<LI>
Options typically precede other non-option arguments.
<P>
The implementation of <CODE>getopt</CODE> in the GNU C library normally makes
it appear as if all the option arguments were specified before all the
non-option arguments for the purposes of parsing, even if the user of
your program intermixed option and non-option arguments.  It does this
by reordering the elements of the <VAR>argv</VAR> array.  This behavior is
nonstandard; if you want to suppress it, define the
<CODE>_POSIX_OPTION_ORDER</CODE> environment variable.  See section <A HREF="library_22.html#SEC394" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_22.html#SEC394">Standard Environment Variables</A>.
<P>
<LI>
The argument <SAMP>`--'</SAMP> terminates all options; any following arguments
are treated as non-option arguments, even if they begin with a hyphen.
<P>
<LI>
A token consisting of a single hyphen character is interpreted as an
ordinary non-option argument.  By convention, it is used to specify
input from or output to the standard input and output streams.
<P>
<LI>
Options may be supplied in any order, or appear multiple times.  The
interpretation is left up to the particular application program.
</UL>
<A NAME="IDX1631"></A>
<P>
GNU adds <DFN>long options</DFN> to these conventions.  Long options consist
of <SAMP>`--'</SAMP> followed by a name made of alphanumeric characters and
dashes.  Option names are typically one to three words long, with
hyphens to separate words.  Users can abbreviate the option names as
long as the abbreviations are unique.
<P>
To specify an argument for a long option, write
<SAMP>`--<VAR>name</VAR>=<VAR>value</VAR>'</SAMP>.  This syntax enables a long option to
accept an argument that is itself optional.
<P>
Eventually, the GNU system will provide completion for long option names
in the shell.
<P>
<A NAME="IDX1632"></A>
<A NAME="IDX1633"></A>
<A NAME="IDX1634"></A>
<H3><A NAME="SEC388" HREF="library_toc.html#SEC388" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC388">Parsing Program Options</A></H3>
<P>
Here are the details about how to call the <CODE>getopt</CODE> function.  To
use this facility, your program must include the header file
<TT>`unistd.h'</TT>.
<A NAME="IDX1635"></A>
<P>
<A NAME="IDX1636"></A>
<U>Variable:</U> int <B>opterr</B><P>
If the value of this variable is nonzero, then <CODE>getopt</CODE> prints an
error message to the standard error stream if it encounters an unknown
option character or an option with a missing required argument.  This is
the default behavior.  If you set this variable to zero, <CODE>getopt</CODE>
does not print any messages, but it still returns the character <CODE>?</CODE>
to indicate an error.
<P>
<A NAME="IDX1637"></A>
<U>Variable:</U> int <B>optopt</B><P>
When <CODE>getopt</CODE> encounters an unknown option character or an option
with a missing required argument, it stores that option character in
this variable.  You can use this for providing your own diagnostic
messages.
<P>
<A NAME="IDX1638"></A>
<U>Variable:</U> int <B>optind</B><P>
This variable is set by <CODE>getopt</CODE> to the index of the next element
of the <VAR>argv</VAR> array to be processed.  Once <CODE>getopt</CODE> has found
all of the option arguments, you can use this variable to determine
where the remaining non-option arguments begin.  The initial value of
this variable is <CODE>1</CODE>.
<P>
<A NAME="IDX1639"></A>
<U>Variable:</U> char * <B>optarg</B><P>
This variable is set by <CODE>getopt</CODE> to point at the value of the
option argument, for those options that accept arguments.
<P>
<A NAME="IDX1640"></A>
<U>Function:</U> int <B>getopt</B> <I>(int <VAR>argc</VAR>, char **<VAR>argv</VAR>, const char *<VAR>options</VAR>)</I><P>
The <CODE>getopt</CODE> function gets the next option argument from the
argument list specified by the <VAR>argv</VAR> and <VAR>argc</VAR> arguments.
Normally these values come directly from the arguments received by
<CODE>main</CODE>.
<P>
The <VAR>options</VAR> argument is a string that specifies the option
characters that are valid for this program.  An option character in this
string can be followed by a colon (<SAMP>`:'</SAMP>) to indicate that it takes a
required argument.
<P>
If the <VAR>options</VAR> argument string begins with a hyphen (<SAMP>`-'</SAMP>), this
is treated specially.  It permits arguments that are not options to be
returned as if they were associated with option character <SAMP>`\0'</SAMP>.
<P>
The <CODE>getopt</CODE> function returns the option character for the next
command line option.  When no more option arguments are available, it
returns <CODE>-1</CODE>.  There may still be more non-option arguments; you
must compare the external variable <CODE>optind</CODE> against the <VAR>argc</VAR>
parameter to check this.
<P>
If the option has an argument, <CODE>getopt</CODE> returns the argument by
storing it in the varables <VAR>optarg</VAR>.  You don't ordinarily need to
copy the <CODE>optarg</CODE> string, since it is a pointer into the original
<VAR>argv</VAR> array, not into a static area that might be overwritten.
<P>
If <CODE>getopt</CODE> finds an option character in <VAR>argv</VAR> that was not
included in <VAR>options</VAR>, or a missing option argument, it returns
<SAMP>`?'</SAMP> and sets the external variable <CODE>optopt</CODE> to the actual
option character.  If the first character of <VAR>options</VAR> is a colon
(<SAMP>`:'</SAMP>), then <CODE>getopt</CODE> returns <SAMP>`:'</SAMP> instead of <SAMP>`?'</SAMP> to
indicate a missing option argument.  In addition, if the external
variable <CODE>opterr</CODE> is nonzero (which is the default), <CODE>getopt</CODE>
prints an error message.
<P>
<H3><A NAME="SEC389" HREF="library_toc.html#SEC389" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC389">Example of Parsing Arguments with <CODE>getopt</CODE></A></H3>
<P>
Here is an example showing how <CODE>getopt</CODE> is typically used.  The
key points to notice are:
<P>
<UL>
<LI>
Normally, <CODE>getopt</CODE> is called in a loop.  When <CODE>getopt</CODE> returns
<CODE>-1</CODE>, indicating no more options are present, the loop terminates.
<P>
<LI>
A <CODE>switch</CODE> statement is used to dispatch on the return value from
<CODE>getopt</CODE>.  In typical use, each case just sets a variable that
is used later in the program.
<P>
<LI>
A second loop is used to process the remaining non-option arguments.
</UL>
<P>
<PRE>
#include &#60;unistd.h&#62;
#include &#60;stdio.h&#62;

int 
main (int argc, char **argv)
{
  int aflag = 0;
  int bflag = 0;
  char *cvalue = NULL;
  int index;
  int c;

  opterr = 0;

  while ((c = getopt (argc, argv, "abc:")) != -1)
    switch (c)
      {
      case 'a':
        aflag = 1;
        break;
      case 'b':
        bflag = 1;
        break;
      case 'c':
        cvalue = optarg;
        break;
      case '?':
        if (isprint (optopt))
          fprintf (stderr, "Unknown option `-%c'.\n", optopt);
        else
          fprintf (stderr,
                   "Unknown option character `\\x%x'.\n",
                   optopt);
        return 1;
      default:
        abort ();
      }

  printf ("aflag = %d, bflag = %d, cvalue = %s\n", aflag, bflag, cvalue);

  for (index = optind; index &#60; argc; index++)
    printf ("Non-option argument %s\n", argv[index]);
  return 0;
}
</PRE>
<P>
Here are some examples showing what this program prints with different
combinations of arguments:
<P>
<PRE>
% testopt
aflag = 0, bflag = 0, cvalue = (null)

% testopt -a -b
aflag = 1, bflag = 1, cvalue = (null)

% testopt -ab
aflag = 1, bflag = 1, cvalue = (null)

% testopt -c foo
aflag = 0, bflag = 0, cvalue = foo

% testopt -cfoo
aflag = 0, bflag = 0, cvalue = foo

% testopt arg1
aflag = 0, bflag = 0, cvalue = (null)
Non-option argument arg1

% testopt -a arg1
aflag = 1, bflag = 0, cvalue = (null)
Non-option argument arg1

% testopt -c foo arg1
aflag = 0, bflag = 0, cvalue = foo
Non-option argument arg1

% testopt -a -- -b
aflag = 1, bflag = 0, cvalue = (null)
Non-option argument -b

% testopt -a -
aflag = 1, bflag = 0, cvalue = (null)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91精品精华液一区二区三区| 三级欧美韩日大片在线看| 国产精品99久久久久久似苏梦涵 | 91福利社在线观看| 亚洲欧美在线高清| 色偷偷一区二区三区| 亚洲激情综合网| 91.com在线观看| 国产一区二区女| 亚洲欧洲日韩综合一区二区| 色婷婷综合中文久久一本| 亚洲国产美国国产综合一区二区 | 精品久久久网站| 欧美中文一区二区三区| 午夜国产精品一区| 久久亚洲捆绑美女| 91丨porny丨蝌蚪视频| 亚洲成人av免费| 欧美精品一区二区三| 不卡视频在线看| 日韩综合小视频| 国产亚洲成av人在线观看导航| 91丝袜美腿高跟国产极品老师 | 日韩电影网1区2区| 久久精品人人做人人爽97| 91在线精品一区二区三区| 午夜视频一区在线观看| 国产拍揄自揄精品视频麻豆| 欧美日韩一区精品| 国产一区久久久| 亚洲一区二区三区四区五区黄| 日韩欧美你懂的| 色婷婷激情一区二区三区| 久久99国产乱子伦精品免费| 亚洲欧洲中文日韩久久av乱码| 日韩美女一区二区三区| av网站免费线看精品| 美女视频黄久久| 亚洲综合色视频| 国产精品久久久久久久久晋中| 欧美人与禽zozo性伦| av午夜一区麻豆| 国产尤物一区二区在线| 偷偷要91色婷婷| 综合久久一区二区三区| 国产亚洲综合性久久久影院| 欧美日韩国产综合视频在线观看| 成人激情免费电影网址| 久久精品国产成人一区二区三区| 亚洲一区在线观看视频| 亚洲素人一区二区| 久久久综合九色合综国产精品| 欧美色综合久久| 色综合久久综合中文综合网| 国产精品一区二区在线播放| 日韩不卡在线观看日韩不卡视频| 亚洲欧美日韩国产中文在线| 国产精品青草久久| 国产亚洲女人久久久久毛片| 国产精品免费丝袜| 国产婷婷色一区二区三区在线| 91精品久久久久久蜜臀| 欧美日韩高清一区二区不卡| 色偷偷成人一区二区三区91 | 欧美激情一区二区三区在线| 日韩视频免费直播| 欧美裸体一区二区三区| 欧美色图免费看| 在线观看一区二区精品视频| 色先锋aa成人| 欧美在线综合视频| 在线免费视频一区二区| 色哟哟亚洲精品| 欧洲日韩一区二区三区| 日本精品一区二区三区四区的功能| 成人精品亚洲人成在线| www.亚洲人| gogo大胆日本视频一区| 99久久精品免费看国产免费软件| av爱爱亚洲一区| 日本道精品一区二区三区| 色婷婷亚洲精品| 欧美三级视频在线观看| 在线播放国产精品二区一二区四区 | 欧美三级日韩在线| 欧美日韩免费在线视频| 欧美日韩激情一区二区| 日韩丝袜美女视频| 精品国产乱码久久久久久蜜臀 | 欧美日韩日日夜夜| 7777精品伊人久久久大香线蕉 | 美女视频黄免费的久久| 国产一区二区不卡| 国产成人精品午夜视频免费| 白白色 亚洲乱淫| 色香蕉久久蜜桃| 欧美日韩色综合| 欧美成人福利视频| 欧美国产视频在线| 一区二区高清在线| 日韩电影在线观看电影| 国产乱码精品一区二区三区忘忧草| www.欧美亚洲| 欧美欧美午夜aⅴ在线观看| 欧美r级在线观看| 亚洲欧洲另类国产综合| 天天亚洲美女在线视频| 国产精品99久久久久久宅男| 色综合久久66| 日韩免费高清av| 中文字幕在线观看不卡视频| 亚洲大片在线观看| 国产一区二区福利视频| 欧美性色综合网| 一区二区三区鲁丝不卡| 偷窥国产亚洲免费视频| 福利一区二区在线| 欧美影院午夜播放| 国产亚洲一本大道中文在线| 亚洲三级在线观看| 久久国产精品区| 91女神在线视频| 欧美精品一区二区三区很污很色的| 亚洲精品五月天| 国产麻豆一精品一av一免费| 欧美私模裸体表演在线观看| 久久久国产精华| 爽好久久久欧美精品| 99re这里只有精品首页| 精品久久久久久久人人人人传媒| 1024成人网| 国产高清久久久| 日韩欧美你懂的| 亚洲国产视频a| 99国产欧美另类久久久精品| 精品国产一区二区精华| 亚洲成人一区在线| 91一区二区三区在线观看| www久久精品| 日韩av午夜在线观看| 一本久道久久综合中文字幕| 久久久五月婷婷| 老司机免费视频一区二区| 欧洲国内综合视频| 自拍偷拍欧美精品| 成人免费高清视频在线观看| 欧美成人精品福利| 秋霞av亚洲一区二区三| 欧美三级蜜桃2在线观看| 亚洲视频香蕉人妖| 成人app在线观看| 国产日韩欧美电影| 国产一区二区久久| 久久亚洲二区三区| 精品一区二区在线免费观看| 91精品一区二区三区在线观看| 亚洲黄一区二区三区| 99精品久久免费看蜜臀剧情介绍| 久久久国产一区二区三区四区小说 | 夜夜嗨av一区二区三区| av中文字幕在线不卡| 国产精品视频线看| 懂色av一区二区三区蜜臀| 精品黑人一区二区三区久久| 久久国产精品第一页| 日韩免费看网站| 国产一区二区三区四区在线观看| 日韩一区二区三区电影在线观看| 青青草国产成人av片免费| 91精品麻豆日日躁夜夜躁| 秋霞电影网一区二区| 日韩欧美一二区| 国产精品一色哟哟哟| 欧美激情在线免费观看| 99精品国产99久久久久久白柏| 日韩美女啊v在线免费观看| 色av一区二区| 午夜精品久久久久影视| 91精品国产综合久久福利软件 | 丁香激情综合国产| 中文字幕中文乱码欧美一区二区| 99视频一区二区| 亚洲一区二区三区国产| 7777女厕盗摄久久久| 国产一区 二区 三区一级| 日本一区二区成人| 日本丰满少妇一区二区三区| 五月婷婷激情综合| 丝袜亚洲精品中文字幕一区| 日韩一区二区三区四区| 国产一区二区看久久| 亚洲人精品午夜| 欧美日韩国产精品成人| 国产在线日韩欧美| 综合久久一区二区三区| 欧美二区三区的天堂| 国产98色在线|日韩| 亚洲一区二区偷拍精品| 精品久久久久久最新网址| jvid福利写真一区二区三区|