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

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

?? library_11.html

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

<TITLE>The GNU C Library - Input/Output on Streams</TITLE>
<P>Go to the <A HREF="library_10.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_10.html">previous</A>, <A HREF="library_12.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_12.html">next</A> section.<P>
<H1><A NAME="SEC117" HREF="library_toc.html#SEC117" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC117">Input/Output on Streams</A></H1>
<P>
This chapter describes the functions for creating streams and performing
input and output operations on them.  As discussed in section <A HREF="library_10.html#SEC108" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_10.html#SEC108">Input/Output Overview</A>, a stream is a fairly abstract, high-level concept
representing a communications channel to a file, device, or process.
<P>
<H2><A NAME="SEC118" HREF="library_toc.html#SEC118" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC118">Streams</A></H2>
<P>
For historical reasons, the type of the C data structure that represents
a stream is called <CODE>FILE</CODE> rather than "stream".  Since most of
the library functions deal with objects of type <CODE>FILE *</CODE>, sometimes
the term <DFN>file pointer</DFN> is also used to mean "stream".  This leads
to unfortunate confusion over terminology in many books on C.  This
manual, however, is careful to use the terms "file" and "stream"
only in the technical sense.
<A NAME="IDX437"></A>
<A NAME="IDX438"></A>
<P>
The <CODE>FILE</CODE> type is declared in the header file <TT>`stdio.h'</TT>.
<P>
<A NAME="IDX439"></A>
<U>Data Type:</U> <B>FILE</B><P>
This is the data type is used to represent stream objects.  A
<CODE>FILE</CODE> object holds all of the internal state information about the
connection to the associated file, including such things as the file
position indicator and buffering information.  Each stream also has
error and end-of-file status indicators that can be tested with the
<CODE>ferror</CODE> and <CODE>feof</CODE> functions; see section <A HREF="library_11.html#SEC156" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_11.html#SEC156">End-Of-File and Errors</A>.
<P>
<CODE>FILE</CODE> objects are allocated and managed internally by the
input/output library functions.  Don't try to create your own objects of
type <CODE>FILE</CODE>; let the library do it.  Your programs should
deal only with pointers to these objects (that is, <CODE>FILE *</CODE> values)
rather than the objects themselves.
<P>
<A NAME="IDX440"></A>
<A NAME="IDX441"></A>
<H2><A NAME="SEC119" HREF="library_toc.html#SEC119" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC119">Standard Streams</A></H2>
<P>
When the <CODE>main</CODE> function of your program is invoked, it already has
three predefined streams open and available for use.  These represent
the "standard" input and output channels that have been established
for the process.
<P>
These streams are declared in the header file <TT>`stdio.h'</TT>.
<A NAME="IDX442"></A>
<P>
<A NAME="IDX443"></A>
<U>Macro:</U> FILE * <B>stdin</B><P>
The <DFN>standard input</DFN> stream, which is the normal source of input for the
program.
<A NAME="IDX444"></A>
<P>
<A NAME="IDX445"></A>
<U>Macro:</U> FILE * <B>stdout</B><P>
The <DFN>standard output</DFN> stream, which is used for normal output from
the program.
<A NAME="IDX446"></A>
<P>
<A NAME="IDX447"></A>
<U>Macro:</U> FILE * <B>stderr</B><P>
The <DFN>standard error</DFN> stream, which is used for error messages and
diagnostics issued by the program.
<A NAME="IDX448"></A>
<P>
In the GNU system, you can specify what files or processes correspond to
these streams using the pipe and redirection facilities provided by the
shell.  (The primitives shells use to implement these facilities are
described in section <A HREF="library_13.html#SEC187" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_13.html#SEC187">File System Interface</A>.)  Most other operating systems
provide similar mechanisms, but the details of how to use them can vary.
<P>
It is probably not a good idea to close any of the standard streams.
But you can use <CODE>freopen</CODE> to get te effect of closing one and
reopening it.  See section <A HREF="library_11.html#SEC120" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_11.html#SEC120">Opening Streams</A>.
<P>
<H2><A NAME="SEC120" HREF="library_toc.html#SEC120" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC120">Opening Streams</A></H2>
<A NAME="IDX449"></A>
<P>
Opening a file with the <CODE>fopen</CODE> function creates a new stream and
establishes a connection between the stream and a file.  This may
involve creating a new file.  
<A NAME="IDX450"></A>
<P>
Everything described in this section is declared in the header file
<TT>`stdio.h'</TT>.
<P>
<A NAME="IDX451"></A>
<U>Function:</U> FILE * <B>fopen</B> <I>(const char *<VAR>filename</VAR>, const char *<VAR>opentype</VAR>)</I><P>
The <CODE>fopen</CODE> function opens a stream for I/O to the file
<VAR>filename</VAR>, and returns a pointer to the stream.
<P>
The <VAR>opentype</VAR> argument is a string that controls how the file is
opened and specifies attributes of the resulting stream.  It must begin
with one of the following sequences of characters:
<P>
<DL COMPACT>
<DT><SAMP>`r'</SAMP>
<DD>Open an existing file for reading only.
<P>
<DT><SAMP>`w'</SAMP>
<DD>Open the file for writing only.  If the file already exists, it is
truncated to zero length.  Otherwise a new file is created.
<P>
<DT><SAMP>`a'</SAMP>
<DD>Open file for append access; that is, writing at the end of file only.
If the file already exists, its initial contents are unchanged and
output to the stream is appended to the end of the file.
Otherwise, a new, empty file is created.
<P>
<DT><SAMP>`r+'</SAMP>
<DD>Open existing file for both reading and writing.  The initial contents
of the file are unchanged and the initial file position is at the
beginning of the file.
<P>
<DT><SAMP>`w+'</SAMP>
<DD>Open file for both reading and writing.  If the file already exists, it
is truncated to zero length.  Otherwise, a new file is created.
<P>
<DT><SAMP>`a+'</SAMP>
<DD>Open or create file for both reading and appending.  If the file exists,
its initial contents are unchanged.  Otherwise, a new file is
created.  The initial file position for reading might be at either
the beginning or end of the file, but output is always appended
to the end of the file.
</DL>
<P>
As you can see, <SAMP>`+'</SAMP> requests a stream that can do both input and
output.  When using such a stream, you must call <CODE>fflush</CODE>
(see section <A HREF="library_11.html#SEC160" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_11.html#SEC160">Stream Buffering</A>) or a file positioning function such as
<CODE>fseek</CODE> (see section <A HREF="library_11.html#SEC158" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_11.html#SEC158">File Positioning</A>) when switching from reading to
writing or vice versa.  Otherwise, internal buffers might not be emptied
properly.
<P>
The GNU C library defines one additional character for use in
<VAR>opentype</VAR>: the character <SAMP>`x'</SAMP> insists on creating a new
file--if a file <VAR>filename</VAR> already exists, <CODE>fopen</CODE> fails
rather than opening it.  This is equivalent to the <CODE>O_EXCL</CODE> option
to the <CODE>open</CODE> function (see section <A HREF="library_12.html#SEC184" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_12.html#SEC184">File Status Flags</A>).
<P>
The character <SAMP>`b'</SAMP> in <VAR>opentype</VAR> has a standard meaning; it
requests a binary stream rather than a text stream.  But this makes no
difference in POSIX systems (including the GNU system).  If both
<SAMP>`+'</SAMP> and <SAMP>`b'</SAMP> are specified, they can appear in either order.
See section <A HREF="library_11.html#SEC157" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_11.html#SEC157">Text and Binary Streams</A>.
<P>
Any other characters in <VAR>opentype</VAR> are simply ignored.  They may be
meaningful in other systems.
<P>
If the open fails, <CODE>fopen</CODE> returns a null pointer.
<P>
You can have multiple streams (or file descriptors) pointing to the same
file open at the same time.  If you do only input, this works
straightforwardly, but you must be careful if any output streams are
included.  See section <A HREF="library_12.html#SEC176" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_12.html#SEC176">Precautions for Mixing Streams and Descriptors</A>.  This is equally true
whether the streams are in one program (not usual) or in several
programs (which can easily happen).  It may be advantageous to use the
file locking facilities to avoid simultaneous access.  See section <A HREF="library_12.html#SEC185" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_12.html#SEC185">File Locks</A>.
<P>
<A NAME="IDX452"></A>
<U>Macro:</U> int <B>FOPEN_MAX</B><P>
The value of this macro is an integer constant expression that
represents the minimum number of streams that the implementation
guarantees can be open simultaneously.  The value of this constant is at
least eight, which includes the three standard streams <CODE>stdin</CODE>,
<CODE>stdout</CODE>, and <CODE>stderr</CODE>.
<P>
<A NAME="IDX453"></A>
<U>Function:</U> FILE * <B>freopen</B> <I>(const char *<VAR>filename</VAR>, const char *<VAR>opentype</VAR>, FILE *<VAR>stream</VAR>)</I><P>
This function is like a combination of <CODE>fclose</CODE> and <CODE>fopen</CODE>.
It first closes the stream referred to by <VAR>stream</VAR>, ignoring any
errors that are detected in the process.  (Because errors are ignored,
you should not use <CODE>freopen</CODE> on an output stream if you have
actually done any output using the stream.)  Then the file named by
<VAR>filename</VAR> is opened with mode <VAR>opentype</VAR> as for <CODE>fopen</CODE>,
and associated with the same stream object <VAR>stream</VAR>.
<P>
If the operation fails, a null pointer is returned; otherwise,
<CODE>freopen</CODE> returns <VAR>stream</VAR>.
<P>
The main use of <CODE>freopen</CODE> is to connect a standard stream such as
<CODE>stdir</CODE> with a file of your own choice.  This is useful in programs
in which use of a standard stream for certain purposes is hard-coded.
<P>
<H2><A NAME="SEC121" HREF="library_toc.html#SEC121" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC121">Closing Streams</A></H2>
<A NAME="IDX454"></A>
<P>
When a stream is closed with <CODE>fclose</CODE>, the connection between the
stream and the file is cancelled.  After you have closed a stream, you
cannot perform any additional operations on it any more.
<P>
<A NAME="IDX455"></A>
<U>Function:</U> int <B>fclose</B> <I>(FILE *<VAR>stream</VAR>)</I><P>
This function causes <VAR>stream</VAR> to be closed and the connection to
the corresponding file to be broken.  Any buffered output is written
and any buffered input is discarded.  The <CODE>fclose</CODE> function returns
a value of <CODE>0</CODE> if the file was closed successfully, and <CODE>EOF</CODE>
if an error was detected. 
<P>
It is important to check for errors when you call <CODE>fclose</CODE> to close
an output stream, because real, everyday errors can be detected at this
time.  For example, when <CODE>fclose</CODE> writes the remaining buffered
output, it might get an error because the disk is full.  Even if you you
know the buffer is empty, errors can still occur when closing a file if
you are using NFS.
<P>
The function <CODE>fclose</CODE> is declared in <TT>`stdio.h'</TT>.
<P>
If the <CODE>main</CODE> function to your program returns, or if you call the
<CODE>exit</CODE> function (see section <A HREF="library_22.html#SEC396" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_22.html#SEC396">Normal Termination</A>), all open streams are
automatically closed properly.  If your program terminates in any other
manner, such as by calling the <CODE>abort</CODE> function (see section <A HREF="library_22.html#SEC399" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_22.html#SEC399">Aborting a Program</A>) or from a fatal signal (see section <A HREF="library_21.html#SEC330" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC330">Signal Handling</A>), open streams
might not be closed properly.  Buffered output may not be flushed and
files may not be complete.  For more information on buffering of
streams, see section <A HREF="library_11.html#SEC160" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_11.html#SEC160">Stream Buffering</A>.
<P>
<H2><A NAME="SEC122" HREF="library_toc.html#SEC122" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC122">Simple Output by Characters or Lines</A></H2>
<A NAME="IDX456"></A>
<P>
This section describes functions for performing character- and
line-oriented output.  Largely for historical compatibility, there are
several variants of these functions, but as a matter of style (and for
simplicity!) we suggest you stick with using <CODE>fputc</CODE> and
<CODE>fputs</CODE>, and perhaps <CODE>putc</CODE> and <CODE>putchar</CODE>.
<P>
These functions are declared in the header file <TT>`stdio.h'</TT>.
<A NAME="IDX457"></A>
<P>
<A NAME="IDX458"></A>
<U>Function:</U> int <B>fputc</B> <I>(int <VAR>c</VAR>, FILE *<VAR>stream</VAR>)</I><P>
The <CODE>fputc</CODE> function converts the character <VAR>c</VAR> to type
<CODE>unsigned char</CODE>, and writes it to the stream <VAR>stream</VAR>.  
<CODE>EOF</CODE> is returned if a write error occurs; otherwise the
character <VAR>c</VAR> is returned.
<P>
<A NAME="IDX459"></A>
<U>Function:</U> int <B>putc</B> <I>(int <VAR>c</VAR>, FILE *<VAR>stream</VAR>)</I><P>
This is just like <CODE>fputc</CODE>, except that most systems implement it as
a macro, making it faster.  One consequence is that it may evaluate the
<VAR>stream</VAR> argument more than once.
<P>
<A NAME="IDX460"></A>
<U>Function:</U> int <B>putchar</B> <I>(int <VAR>c</VAR>)</I><P>
The <CODE>putchar</CODE> function is equivalent to <CODE>fputc</CODE> with
<CODE>stdout</CODE> as the value of the <VAR>stream</VAR> argument.
<P>
<A NAME="IDX461"></A>
<U>Function:</U> int <B>fputs</B> <I>(const char *<VAR>s</VAR>, FILE *<VAR>stream</VAR>)</I><P>
The function <CODE>fputs</CODE> writes the string <VAR>s</VAR> to the stream

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国产馆在线真实露脸 | 国产精品资源在线观看| 亚洲一区二区在线视频| 亚洲欧美乱综合| 亚洲情趣在线观看| 最新热久久免费视频| 一区二区三区精品在线观看| 亚洲黄色免费网站| 五月综合激情婷婷六月色窝| 婷婷中文字幕综合| 久久精品72免费观看| 精品亚洲免费视频| 高清不卡一区二区在线| 99精品视频一区二区| 在线观看网站黄不卡| 91 com成人网| 精品盗摄一区二区三区| 中文字幕乱码亚洲精品一区| 成人免费一区二区三区视频| 亚洲尤物视频在线| 午夜精品成人在线| 国产99一区视频免费| 成人午夜电影网站| 91成人免费在线| 精品免费日韩av| 综合久久国产九一剧情麻豆| 午夜精品一区二区三区免费视频| 麻豆精品一区二区av白丝在线| 国产福利一区二区三区视频在线| 91丨porny丨国产| 在线不卡a资源高清| 国产亚洲一区二区三区| 亚洲一区成人在线| 国产精品综合在线视频| 91免费国产视频网站| 欧美一区二区三区影视| 国产精品美女久久久久av爽李琼| 五月天激情小说综合| 国产精品亚洲а∨天堂免在线| 色就色 综合激情| 精品成人a区在线观看| 国产精品国产三级国产三级人妇| 天天影视涩香欲综合网| 成人av免费网站| 欧美成人video| 午夜欧美电影在线观看| 成人av片在线观看| 2021中文字幕一区亚洲| 亚洲成a人在线观看| a亚洲天堂av| 久久久精品国产免大香伊| 午夜影视日本亚洲欧洲精品| eeuss鲁片一区二区三区在线看 | 午夜精品久久久久久不卡8050| 国产精一品亚洲二区在线视频| 欧美又粗又大又爽| 国产精品视频一二三| 韩国成人在线视频| 欧美精品123区| 亚洲最大的成人av| 色偷偷88欧美精品久久久| 欧美高清在线一区二区| 极品尤物av久久免费看| 欧美一级专区免费大片| 亚洲成av人片一区二区梦乃| 91国产成人在线| 亚洲乱码国产乱码精品精小说| 成人小视频免费观看| 久久久亚洲高清| 国产毛片一区二区| 久久综合久久久久88| 久久精品国产免费看久久精品| 欧美日韩小视频| 日韩精品免费视频人成| 欧美日韩精品专区| 丝袜美腿亚洲一区| 欧美刺激午夜性久久久久久久| 天天综合色天天综合| 日韩欧美二区三区| 久草这里只有精品视频| 久久久精品国产免大香伊| 国产精品一区二区91| 欧美韩国日本综合| 99re6这里只有精品视频在线观看| 中文字幕在线一区免费| 91视频你懂的| 亚洲不卡av一区二区三区| 欧美精品一级二级三级| 麻豆精品一区二区综合av| 久久精品一区四区| 91久久久免费一区二区| 亚洲美腿欧美偷拍| 欧美日韩在线不卡| 国产在线一区二区综合免费视频| 26uuu亚洲| av影院午夜一区| 亚洲成人激情av| 欧美精品一区二区三区在线播放 | 国产精品国产a| 在线精品亚洲一区二区不卡| 亚洲国产cao| 精品国产乱码久久久久久图片 | 亚洲精品日韩专区silk| 欧美日韩在线播| 国产美女娇喘av呻吟久久| 亚洲精品你懂的| 日韩精品在线看片z| 91丨国产丨九色丨pron| 全部av―极品视觉盛宴亚洲| 国产精品国模大尺度视频| 欧美精品日韩综合在线| 国产成人综合网| 亚洲综合色视频| 久久久久久久电影| 欧美日韩精品二区第二页| 国产精品亚洲а∨天堂免在线| 亚洲精品久久嫩草网站秘色| 精品日韩一区二区三区免费视频| 波多野结衣一区二区三区| 秋霞午夜av一区二区三区| 自拍偷在线精品自拍偷无码专区 | 韩国欧美国产一区| 亚洲午夜在线视频| 国产精品视频在线看| 日韩一区二区三区观看| 色视频欧美一区二区三区| 国产91富婆露脸刺激对白| 日本中文字幕不卡| 亚洲国产精品一区二区www在线 | 不卡一区二区三区四区| 免费人成在线不卡| 亚洲成人免费视| 日韩理论电影院| 日本一区二区三区电影| www欧美成人18+| 欧美一区二区视频在线观看2022| 色综合一区二区三区| 大美女一区二区三区| 久久精品99国产精品| 老鸭窝一区二区久久精品| 亚洲午夜久久久久中文字幕久| 国产精品久久久久一区二区三区 | 成人黄色电影在线| 国产一区二区在线电影| 久久精品99国产精品日本| 美脚の诱脚舐め脚责91 | 国产亚洲精品免费| 欧美刺激脚交jootjob| 欧美一区二区三区四区在线观看| 欧美午夜精品一区二区蜜桃| 色天使色偷偷av一区二区| 99精品黄色片免费大全| 成人av电影观看| 99久久精品久久久久久清纯| 99久久精品情趣| 成人av资源在线| 91影视在线播放| 在线视频综合导航| 欧美日韩国产在线观看| 在线播放视频一区| 欧美一区国产二区| 亚洲精品在线三区| 欧美激情资源网| 亚洲人吸女人奶水| 亚洲综合激情网| 日韩 欧美一区二区三区| 国产一区欧美二区| 成人一区在线观看| 色av成人天堂桃色av| 欧美精选一区二区| 久久久久久久久久久久久夜| 国产精品入口麻豆九色| 亚洲精品第一国产综合野| 亚洲va国产天堂va久久en| 美女国产一区二区| 国产69精品久久99不卡| 色欧美88888久久久久久影院| 在线精品视频免费观看| 欧美另类高清zo欧美| 精品久久久久一区二区国产| 国产精品青草综合久久久久99| 亚洲欧美激情一区二区| 日本视频在线一区| 国产精品系列在线观看| 色就色 综合激情| 欧美va在线播放| 一区二区三区在线免费播放| 蜜臀久久99精品久久久久宅男| 盗摄精品av一区二区三区| 欧美日韩国产综合一区二区| 久久精品在线观看| 天天av天天翘天天综合网| 成人精品一区二区三区中文字幕| 欧美亚洲综合久久| 国产日韩亚洲欧美综合| 水蜜桃久久夜色精品一区的特点 | 国产精品色婷婷| 日韩和的一区二区| 91网站视频在线观看| 精品捆绑美女sm三区|