369 lines
16 KiB
HTML
369 lines
16 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title><stdio.h></title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="<stdio.h>"></a> <a name="tag_13_49"></a><!-- <stdio.h> -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_13_49_01"></a>NAME</h4>
|
|
|
|
<blockquote>stdio.h - standard buffered input/output</blockquote>
|
|
|
|
<h4><a name="tag_13_49_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><tt>#include <stdio.h></tt></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_49_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"
|
|
border="0"> Some of the functionality described on this reference page extends the ISO C standard. Applications shall define
|
|
the appropriate feature test macro (see the System Interfaces volume of IEEE Std 1003.1-2001, <a href=
|
|
"../functions/xsh_chap02_02.html">Section 2.2, The Compilation Environment</a>) to enable the visibility of these symbols in this
|
|
header. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div>
|
|
|
|
<p>The <i><stdio.h></i> header shall define the following macros as positive integer constant expressions:</p>
|
|
|
|
<dl compact>
|
|
<dt>BUFSIZ</dt>
|
|
|
|
<dd>Size of <i><stdio.h></i> buffers.</dd>
|
|
|
|
<dt>_IOFBF</dt>
|
|
|
|
<dd>Input/output fully buffered.</dd>
|
|
|
|
<dt>_IOLBF</dt>
|
|
|
|
<dd>Input/output line buffered.</dd>
|
|
|
|
<dt>_IONBF</dt>
|
|
|
|
<dd>Input/output unbuffered.</dd>
|
|
|
|
<dt>L_ctermid</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Maximum size of character array to hold <a href="../functions/ctermid.html"><i>ctermid</i>()</a> output. <img src=
|
|
"../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
|
|
<dt>L_tmpnam</dt>
|
|
|
|
<dd>Maximum size of character array to hold <a href="../functions/tmpnam.html"><i>tmpnam</i>()</a> output.</dd>
|
|
|
|
<dt>SEEK_CUR</dt>
|
|
|
|
<dd>Seek relative to current position.</dd>
|
|
|
|
<dt>SEEK_END</dt>
|
|
|
|
<dd>Seek relative to end-of-file.</dd>
|
|
|
|
<dt>SEEK_SET</dt>
|
|
|
|
<dd>Seek relative to start-of-file.</dd>
|
|
</dl>
|
|
|
|
<p>The following macros shall be defined as positive integer constant expressions which denote implementation limits:</p>
|
|
|
|
<dl compact>
|
|
<dt>{FILENAME_MAX}</dt>
|
|
|
|
<dd>Maximum size in bytes of the longest filename string that the implementation guarantees can be opened.</dd>
|
|
|
|
<dt>{FOPEN_MAX}</dt>
|
|
|
|
<dd>Number of streams which the implementation guarantees can be open simultaneously. The value is at least eight.</dd>
|
|
|
|
<dt>{TMP_MAX}</dt>
|
|
|
|
<dd>Minimum number of unique filenames generated by <a href="../functions/tmpnam.html"><i>tmpnam</i>()</a>. Maximum number of times
|
|
an application can call <a href="../functions/tmpnam.html"><i>tmpnam</i>()</a> reliably. The value of {TMP_MAX} is at least 25.
|
|
<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
On XSI-conformant systems, the value of {TMP_MAX} is at least 10000. <img src="../images/opt-end.gif" alt="[Option End]"
|
|
border="0"></dd>
|
|
</dl>
|
|
|
|
<p>The following macro name shall be defined as a negative integer constant expression:</p>
|
|
|
|
<dl compact>
|
|
<dt>EOF</dt>
|
|
|
|
<dd>End-of-file return value.</dd>
|
|
</dl>
|
|
|
|
<p>The following macro name shall be defined as a null pointer constant:</p>
|
|
|
|
<dl compact>
|
|
<dt>NULL</dt>
|
|
|
|
<dd>Null pointer.</dd>
|
|
</dl>
|
|
|
|
<p>The following macro name shall be defined as a string constant:</p>
|
|
|
|
<dl compact>
|
|
<dt>P_tmpdir</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Default directory prefix for <a href="../functions/tempnam.html"><i>tempnam</i>()</a>. <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></dd>
|
|
</dl>
|
|
|
|
<p>The following shall be defined as expressions of type "pointer to <b>FILE</b>" that point to the <b>FILE</b> objects
|
|
associated, respectively, with the standard error, input, and output streams:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>stderr</i></dt>
|
|
|
|
<dd>Standard error output stream.</dd>
|
|
|
|
<dt><i>stdin</i></dt>
|
|
|
|
<dd>Standard input stream.</dd>
|
|
|
|
<dt><i>stdout</i></dt>
|
|
|
|
<dd>Standard output stream.</dd>
|
|
</dl>
|
|
|
|
<p>The following data types shall be defined through <b>typedef</b>:</p>
|
|
|
|
<dl compact>
|
|
<dt><b>FILE</b></dt>
|
|
|
|
<dd>A structure containing information about a file.</dd>
|
|
|
|
<dt><b>fpos_t</b></dt>
|
|
|
|
<dd>A non-array type containing all information needed to specify uniquely every position within a file.</dd>
|
|
|
|
<dt><b>va_list</b></dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
As described in <a href="stdarg.h.html"><i><stdarg.h></i></a> . <img src="../images/opt-end.gif" alt="[Option End]" border=
|
|
"0"></dd>
|
|
|
|
<dt><b>size_t</b></dt>
|
|
|
|
<dd>As described in <a href="stddef.h.html"><i><stddef.h></i></a> .</dd>
|
|
</dl>
|
|
|
|
<p>The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.</p>
|
|
|
|
<pre>
|
|
<tt>void clearerr(FILE *);
|
|
<sup>[<a href="javascript:open_code('CX')">CX</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
char *ctermid(char *);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
int fclose(FILE *);
|
|
<sup>[<a href="javascript:open_code('CX')">CX</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
FILE *fdopen(int, const char *);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
int feof(FILE *);
|
|
int ferror(FILE *);
|
|
int fflush(FILE *);
|
|
int fgetc(FILE *);
|
|
int fgetpos(FILE *restrict, fpos_t *restrict);
|
|
char *fgets(char *restrict, int, FILE *restrict);
|
|
<sup>[<a href="javascript:open_code('CX')">CX</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
int fileno(FILE *);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
<sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
void flockfile(FILE *);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
FILE *fopen(const char *restrict, const char *restrict);
|
|
int fprintf(FILE *restrict, const char *restrict, ...);
|
|
int fputc(int, FILE *);
|
|
int fputs(const char *restrict, FILE *restrict);
|
|
size_t fread(void *restrict, size_t, size_t, FILE *restrict);
|
|
FILE *freopen(const char *restrict, const char *restrict,
|
|
FILE *restrict);
|
|
int fscanf(FILE *restrict, const char *restrict, ...);
|
|
int fseek(FILE *, long, int);
|
|
<sup>[<a href="javascript:open_code('CX')">CX</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
int fseeko(FILE *, off_t, int);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
int fsetpos(FILE *, const fpos_t *);
|
|
long ftell(FILE *);
|
|
<sup>[<a href="javascript:open_code('CX')">CX</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
off_t ftello(FILE *);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
<sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
int ftrylockfile(FILE *);
|
|
void funlockfile(FILE *);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict);
|
|
int getc(FILE *);
|
|
int getchar(void);
|
|
<sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
int getc_unlocked(FILE *);
|
|
int getchar_unlocked(void);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
char *gets(char *);
|
|
<sup>[<a href="javascript:open_code('CX')">CX</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
int pclose(FILE *);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
void perror(const char *);
|
|
<sup>[<a href="javascript:open_code('CX')">CX</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
FILE *popen(const char *, const char *);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
int printf(const char *restrict, ...);
|
|
int putc(int, FILE *);
|
|
int putchar(int);
|
|
<sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
int putc_unlocked(int, FILE *);
|
|
int putchar_unlocked(int);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
int puts(const char *);
|
|
int remove(const char *);
|
|
int rename(const char *, const char *);
|
|
void rewind(FILE *);
|
|
int scanf(const char *restrict, ...);
|
|
void setbuf(FILE *restrict, char *restrict);
|
|
int setvbuf(FILE *restrict, char *restrict, int, size_t);
|
|
int snprintf(char *restrict, size_t, const char *restrict, ...);
|
|
int sprintf(char *restrict, const char *restrict, ...);
|
|
int sscanf(const char *restrict, const char *restrict, int ...);
|
|
<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
char *tempnam(const char *, const char *);
|
|
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
|
|
FILE *tmpfile(void);
|
|
char *tmpnam(char *);
|
|
int ungetc(int, FILE *);
|
|
int vfprintf(FILE *restrict, const char *restrict, va_list);
|
|
int vfscanf(FILE *restrict, const char *restrict, va_list);
|
|
int vprintf(const char *restrict, va_list);
|
|
int vscanf(const char *restrict, va_list);
|
|
int vsnprintf(char *restrict, size_t, const char *restrict, va_list;
|
|
int vsprintf(char *restrict, const char *restrict, va_list);
|
|
int vsscanf(const char *restrict, const char *restrict, va_list arg);
|
|
</tt>
|
|
</pre>
|
|
|
|
<p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Inclusion of the <i><stdio.h></i> header may also make visible all symbols from <a href=
|
|
"../basedefs/stddef.h.html"><i><stddef.h></i></a>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_13_49_04"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_49_05"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_49_06"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_49_07"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="stdarg.h.html"><i><stdarg.h></i></a> , <a href="stddef.h.html"><i><stddef.h></i></a> , <a href=
|
|
"sys/types.h.html"><i><sys/types.h></i></a> , the System Interfaces volume of IEEE Std 1003.1-2001, <a href=
|
|
"../functions/clearerr.html"><i>clearerr</i>()</a>, <a href="../functions/ctermid.html"><i>ctermid</i>()</a>, <a href=
|
|
"../functions/fclose.html"><i>fclose</i>()</a>, <a href="../functions/fdopen.html"><i>fdopen</i>()</a>, <a href=
|
|
"../functions/fgetc.html"><i>fgetc</i>()</a>, <a href="../functions/fgetpos.html"><i>fgetpos</i>()</a>, <a href=
|
|
"../functions/ferror.html"><i>ferror</i>()</a>, <a href="../functions/feof.html"><i>feof</i>()</a>, <a href=
|
|
"../functions/fflush.html"><i>fflush</i>()</a>, <a href="../functions/fgets.html"><i>fgets</i>()</a>, <a href=
|
|
"../functions/fileno.html"><i>fileno</i>()</a>, <a href="../functions/flockfile.html"><i>flockfile</i>()</a>, <a href=
|
|
"../functions/fopen.html"><i>fopen</i>()</a>, <a href="../functions/fputc.html"><i>fputc</i>()</a>, <a href=
|
|
"../functions/fputs.html"><i>fputs</i>()</a>, <a href="../functions/fread.html"><i>fread</i>()</a>, <a href=
|
|
"../functions/freopen.html"><i>freopen</i>()</a>, <a href="../functions/fseek.html"><i>fseek</i>()</a>, <a href=
|
|
"../functions/fsetpos.html"><i>fsetpos</i>()</a>, <a href="../functions/ftell.html"><i>ftell</i>()</a>, <a href=
|
|
"../functions/fwrite.html"><i>fwrite</i>()</a>, <a href="../functions/getc.html"><i>getc</i>()</a>, <a href=
|
|
"../functions/getc_unlocked.html"><i>getc_unlocked</i>()</a>, <a href="../functions/getwchar.html"><i>getwchar</i>()</a>, <a href=
|
|
"../functions/getchar.html"><i>getchar</i>()</a>, <i>getopt</i>(), <a href="../functions/gets.html"><i>gets</i>()</a>, <a href=
|
|
"../functions/pclose.html"><i>pclose</i>()</a>, <a href="../functions/perror.html"><i>perror</i>()</a>, <a href=
|
|
"../functions/popen.html"><i>popen</i>()</a>, <a href="../functions/printf.html"><i>printf</i>()</a>, <a href=
|
|
"../functions/putc.html"><i>putc</i>()</a>, <a href="../functions/putchar.html"><i>putchar</i>()</a>, <a href=
|
|
"../functions/puts.html"><i>puts</i>()</a>, <a href="../functions/putwchar.html"><i>putwchar</i>()</a>, <a href=
|
|
"../functions/remove.html"><i>remove</i>()</a>, <a href="../functions/rename.html"><i>rename</i>()</a>, <a href=
|
|
"../functions/rewind.html"><i>rewind</i>()</a>, <a href="../functions/scanf.html"><i>scanf</i>()</a>, <a href=
|
|
"../functions/setbuf.html"><i>setbuf</i>()</a>, <a href="../functions/setvbuf.html"><i>setvbuf</i>()</a>, <a href=
|
|
"../functions/sscanf.html"><i>sscanf</i>()</a>, <i>stdin</i>, <a href="../functions/system.html"><i>system</i>()</a>, <a href=
|
|
"../functions/tempnam.html"><i>tempnam</i>()</a>, <a href="../functions/tmpfile.html"><i>tmpfile</i>()</a>, <a href=
|
|
"../functions/tmpnam.html"><i>tmpnam</i>()</a>, <a href="../functions/ungetc.html"><i>ungetc</i>()</a>, <a href=
|
|
"../functions/vfscanf.html"><i>vfscanf</i>()</a>, <a href="../functions/vscanf.html"><i>vscanf</i>()</a>, <a href=
|
|
"../functions/vprintf.html"><i>vprintf</i>()</a>, <a href="../functions/vsscanf.html"><i>vsscanf</i>()</a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_49_08"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 1. Derived from Issue 1 of the SVID.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_49_09"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>The DESCRIPTION is updated for alignment with the POSIX Threads Extension.</p>
|
|
|
|
<p>Large File System extensions are added.</p>
|
|
|
|
<p>The constant L_cuserid and the external variables <i>optarg</i>, <i>opterr</i>, <i>optind</i>, and <i>optopt</i> are marked as
|
|
extensions and LEGACY.</p>
|
|
|
|
<p>The <i>cuserid</i>() and <i>getopt</i>() functions are marked LEGACY.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_49_10"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>The constant L_cuserid and the external variables <i>optarg</i>, <i>opterr</i>, <i>optind</i>, and <i>optopt</i> are removed as
|
|
they were previously marked LEGACY.</p>
|
|
|
|
<p>The <i>cuserid</i>(), <i>getopt</i>(), and <i>getw</i>() functions are removed as they were previously marked LEGACY.</p>
|
|
|
|
<p>Several functions are marked as part of the Thread-Safe Functions option.</p>
|
|
|
|
<p>This reference page is updated to align with the ISO/IEC 9899:1999 standard. Note that the description of the <b>fpos_t</b>
|
|
type is now explicitly updated to exclude array types.</p>
|
|
|
|
<p>Extensions beyond the ISO C standard are marked.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|