亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
日本vs亚洲vs韩国一区三区二区| 久久国产尿小便嘘嘘| 国产专区欧美精品| 国产视频一区在线播放| 韩国精品主播一区二区在线观看| 7878成人国产在线观看| 亚洲成av人综合在线观看| 色一情一伦一子一伦一区| 亚洲欧美综合色| 91色九色蝌蚪| 亚洲成人免费看| 日韩一级高清毛片| 国产精品一区专区| 国产精品久久看| 欧洲人成人精品| 日韩和欧美的一区| 91精品欧美久久久久久动漫| 强制捆绑调教一区二区| 亚洲精品在线一区二区| 成人亚洲精品久久久久软件| 国产精品久久久久aaaa樱花| 欧美视频精品在线| 精品一区二区三区在线观看国产| 亚洲精品在线网站| 91香蕉国产在线观看软件| 五月天国产精品| 欧美一卡二卡在线观看| 精品一区二区三区av| 日韩理论在线观看| 国产亚洲欧美激情| www精品美女久久久tv| 91精品黄色片免费大全| 欧美手机在线视频| 91国产精品成人| 91久久精品网| 欧美色综合网站| 不卡电影一区二区三区| 麻豆久久一区二区| 亚洲一区二区三区自拍| 亚洲天天做日日做天天谢日日欢 | 日韩一区二区三区电影在线观看| 99国产精品一区| 91碰在线视频| 在线欧美日韩国产| 91猫先生在线| 欧美日韩五月天| 精品视频一区 二区 三区| 一本色道a无线码一区v| 亚洲精品网站在线观看| 91视频观看视频| 成人综合在线网站| 麻豆专区一区二区三区四区五区| 国产精品久久久久久久浪潮网站| 欧美麻豆精品久久久久久| av电影在线观看完整版一区二区| 麻豆精品在线播放| 午夜在线成人av| 亚洲成人资源在线| 麻豆视频一区二区| 亚洲高清一区二区三区| 国产欧美日韩不卡| 久久久国产一区二区三区四区小说 | 丝袜脚交一区二区| 亚洲成av人片在www色猫咪| 国产精品美女久久久久久久久久久 | 欧美系列日韩一区| 久久99精品久久久久久动态图| 樱花影视一区二区| 亚洲精品久久嫩草网站秘色| 亚洲欧美综合色| 一区二区三区高清不卡| 一区二区三区四区在线播放 | 在线观看视频一区| 日韩午夜中文字幕| 久久久久久毛片| 国产精品福利影院| 日韩福利电影在线| 日韩专区在线视频| 欧美精品在线一区二区| 欧美年轻男男videosbes| 在线成人av影院| 亚洲国产精品成人综合色在线婷婷| 久久精品日产第一区二区三区高清版 | 亚洲成人自拍网| 激情丁香综合五月| 色婷婷综合久久久中文一区二区| 国产精一区二区三区| 中文字幕av在线一区二区三区| 久久网站热最新地址| 亚洲精品自拍动漫在线| 久久精品国产久精国产爱| 成人h动漫精品一区二| 欧美久久久一区| 亚洲一区在线看| 国产福利一区二区三区视频在线| 色婷婷久久久亚洲一区二区三区 | 久久久久久久性| 日韩高清一区在线| 欧美主播一区二区三区| 日韩制服丝袜av| 国产**成人网毛片九色 | 亚洲一区日韩精品中文字幕| 开心九九激情九九欧美日韩精美视频电影 | 国产一区二区三区日韩| 日韩一区二区免费视频| ●精品国产综合乱码久久久久| 国产黄色精品网站| 国产精品无码永久免费888| 国产在线看一区| 久久精品亚洲一区二区三区浴池 | 欧美国产日本韩| 91麻豆成人久久精品二区三区| 国产精品入口麻豆九色| 欧洲激情一区二区| 秋霞影院一区二区| 国产精品久久久久aaaa樱花| 99久久精品国产毛片| 亚洲成在人线免费| 久久人人97超碰com| 色94色欧美sute亚洲线路一ni| 婷婷中文字幕一区三区| 欧美精品一区二区三区在线播放| 国产99久久久国产精品 | 欧美一级日韩一级| 成人国产精品免费网站| 久久精品国产精品亚洲精品| 久久久久国产免费免费| 成人免费视频一区| 国产性色一区二区| 91麻豆国产福利精品| 日韩 欧美一区二区三区| 国产精品欧美综合在线| 678五月天丁香亚洲综合网| 成人av在线电影| 国产精一区二区三区| 日韩激情av在线| 亚洲国产精品久久久久婷婷884| 欧美精品一区二| 久久久久久夜精品精品免费| 欧美一区二区三区视频免费播放| 91国偷自产一区二区三区观看| 国产一区在线视频| 日本在线不卡视频| 亚洲一区在线观看视频| 亚洲五码中文字幕| 亚洲高清免费视频| 麻豆国产欧美日韩综合精品二区 | 91免费国产视频网站| 国产69精品久久777的优势| 国产一区久久久| 蜜臀av一区二区| 91啪九色porn原创视频在线观看| 色先锋资源久久综合| 欧美一区二区黄| 亚洲天堂网中文字| 秋霞影院一区二区| 99精品视频一区二区三区| 欧美蜜桃一区二区三区 | 色成人在线视频| 欧美大白屁股肥臀xxxxxx| 国产精品夫妻自拍| 精品一区二区三区日韩| 欧美中文字幕不卡| 日本一区二区三级电影在线观看| 亚洲成人黄色小说| 99国产精品一区| 精品国产一区二区在线观看| 亚洲一区视频在线观看视频| 国产盗摄女厕一区二区三区| 欧美日韩国产三级| 亚洲欧洲日本在线| 国产成人综合精品三级| 91精品在线免费| 夜夜揉揉日日人人青青一国产精品| 国产制服丝袜一区| 91精品久久久久久久99蜜桃| 亚洲免费高清视频在线| 成人永久aaa| 欧美成人免费网站| 婷婷国产在线综合| 在线免费观看视频一区| 国产精品不卡在线| 粉嫩av一区二区三区在线播放| 日韩视频在线观看一区二区| 亚洲国产精品一区二区久久| 色综合天天综合在线视频| 国产欧美中文在线| 国产成人鲁色资源国产91色综| 日韩午夜在线观看| 秋霞影院一区二区| 欧美成va人片在线观看| 午夜精品久久久久久久久久久 | 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 欧美v国产在线一区二区三区| 亚洲第一久久影院| 欧美少妇bbb| 日韩国产精品久久久久久亚洲| 欧美视频在线不卡| 丝袜亚洲另类欧美综合| 91麻豆精品国产91久久久久久久久 |