You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

244 satır
18KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>Stdio (The Red Hat newlib C Library)</title>
  7. <meta name="description" content="Stdio (The Red Hat newlib C Library)">
  8. <meta name="keywords" content="Stdio (The Red Hat newlib C Library)">
  9. <meta name="resource-type" content="document">
  10. <meta name="distribution" content="global">
  11. <meta name="Generator" content="makeinfo">
  12. <link href="index.html#Top" rel="start" title="Top">
  13. <link href="Document-Index.html#Document-Index" rel="index" title="Document Index">
  14. <link href="Document-Index.html#SEC_Contents" rel="contents" title="Table of Contents">
  15. <link href="index.html#Top" rel="up" title="Top">
  16. <link href="clearerr.html#clearerr" rel="next" title="clearerr">
  17. <link href="wctrans.html#wctrans" rel="prev" title="wctrans">
  18. <style type="text/css">
  19. <!--
  20. a.summary-letter {text-decoration: none}
  21. blockquote.indentedblock {margin-right: 0em}
  22. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  23. blockquote.smallquotation {font-size: smaller}
  24. div.display {margin-left: 3.2em}
  25. div.example {margin-left: 3.2em}
  26. div.lisp {margin-left: 3.2em}
  27. div.smalldisplay {margin-left: 3.2em}
  28. div.smallexample {margin-left: 3.2em}
  29. div.smalllisp {margin-left: 3.2em}
  30. kbd {font-style: oblique}
  31. pre.display {font-family: inherit}
  32. pre.format {font-family: inherit}
  33. pre.menu-comment {font-family: serif}
  34. pre.menu-preformatted {font-family: serif}
  35. pre.smalldisplay {font-family: inherit; font-size: smaller}
  36. pre.smallexample {font-size: smaller}
  37. pre.smallformat {font-family: inherit; font-size: smaller}
  38. pre.smalllisp {font-size: smaller}
  39. span.nolinebreak {white-space: nowrap}
  40. span.roman {font-family: initial; font-weight: normal}
  41. span.sansserif {font-family: sans-serif; font-weight: normal}
  42. ul.no-bullet {list-style: none}
  43. -->
  44. </style>
  45. </head>
  46. <body lang="en">
  47. <a name="Stdio"></a>
  48. <div class="header">
  49. <p>
  50. Next: <a href="Strings.html#Strings" accesskey="n" rel="next">Strings</a>, Previous: <a href="Ctype.html#Ctype" accesskey="p" rel="prev">Ctype</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Document-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Document-Index.html#Document-Index" title="Index" rel="index">Index</a>]</p>
  51. </div>
  52. <hr>
  53. <a name="Input-and-Output-_0028stdio_002eh_0029"></a>
  54. <h2 class="chapter">4 Input and Output (<samp>stdio.h</samp>)</h2>
  55. <p>This chapter comprises functions to manage files
  56. or other input/output streams. Among these functions are subroutines
  57. to generate or scan strings according to specifications from a format string.
  58. </p>
  59. <p>The underlying facilities for input and output depend on the host
  60. system, but these functions provide a uniform interface.
  61. </p>
  62. <p>The corresponding declarations are in <samp>stdio.h</samp>.
  63. </p>
  64. <p>The reentrant versions of these functions use macros
  65. </p>
  66. <div class="example">
  67. <pre class="example">_stdin_r(<var>reent</var>)
  68. _stdout_r(<var>reent</var>)
  69. _stderr_r(<var>reent</var>)
  70. </pre></div>
  71. <p>instead of the globals <code>stdin</code>, <code>stdout</code>, and
  72. <code>stderr</code>. The argument <var>reent</var> is a pointer to a reentrancy
  73. structure.
  74. </p>
  75. <table class="menu" border="0" cellspacing="0">
  76. <tr><td align="left" valign="top">&bull; <a href="clearerr.html#clearerr" accesskey="1">clearerr</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Clear file or stream error indicator
  77. </td></tr>
  78. <tr><td align="left" valign="top">&bull; <a href="diprintf.html#diprintf" accesskey="2">diprintf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Print to a file descriptor (integer only)
  79. </td></tr>
  80. <tr><td align="left" valign="top">&bull; <a href="dprintf.html#dprintf" accesskey="3">dprintf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Print to a file descriptor
  81. </td></tr>
  82. <tr><td align="left" valign="top">&bull; <a href="fclose.html#fclose" accesskey="4">fclose</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Close a file
  83. </td></tr>
  84. <tr><td align="left" valign="top">&bull; <a href="fcloseall.html#fcloseall" accesskey="5">fcloseall</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Close all files
  85. </td></tr>
  86. <tr><td align="left" valign="top">&bull; <a href="fdopen.html#fdopen" accesskey="6">fdopen</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Turn an open file into a stream
  87. </td></tr>
  88. <tr><td align="left" valign="top">&bull; <a href="feof.html#feof" accesskey="7">feof</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Test for end of file
  89. </td></tr>
  90. <tr><td align="left" valign="top">&bull; <a href="ferror.html#ferror" accesskey="8">ferror</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Test whether read/write error has occurred
  91. </td></tr>
  92. <tr><td align="left" valign="top">&bull; <a href="fflush.html#fflush" accesskey="9">fflush</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Flush buffered file output
  93. </td></tr>
  94. <tr><td align="left" valign="top">&bull; <a href="fgetc.html#fgetc">fgetc</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get a character from a file or stream
  95. </td></tr>
  96. <tr><td align="left" valign="top">&bull; <a href="fgetpos.html#fgetpos">fgetpos</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Record position in a stream or file
  97. </td></tr>
  98. <tr><td align="left" valign="top">&bull; <a href="fgets.html#fgets">fgets</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get character string from a file or stream
  99. </td></tr>
  100. <tr><td align="left" valign="top">&bull; <a href="fgetwc.html#fgetwc">fgetwc</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get a wide character from a file or stream
  101. </td></tr>
  102. <tr><td align="left" valign="top">&bull; <a href="fgetws.html#fgetws">fgetws</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get a wide character string from a file or stream
  103. </td></tr>
  104. <tr><td align="left" valign="top">&bull; <a href="fileno.html#fileno">fileno</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get file descriptor associated with stream
  105. </td></tr>
  106. <tr><td align="left" valign="top">&bull; <a href="fmemopen.html#fmemopen">fmemopen</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Open a stream around a fixed-length buffer
  107. </td></tr>
  108. <tr><td align="left" valign="top">&bull; <a href="fopen.html#fopen">fopen</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Open a file
  109. </td></tr>
  110. <tr><td align="left" valign="top">&bull; <a href="fopencookie.html#fopencookie">fopencookie</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Open a stream with custom callbacks
  111. </td></tr>
  112. <tr><td align="left" valign="top">&bull; <a href="fpurge.html#fpurge">fpurge</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Discard all pending I/O on a stream
  113. </td></tr>
  114. <tr><td align="left" valign="top">&bull; <a href="fputc.html#fputc">fputc</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write a character on a stream or file
  115. </td></tr>
  116. <tr><td align="left" valign="top">&bull; <a href="fputs.html#fputs">fputs</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write a character string in a file or stream
  117. </td></tr>
  118. <tr><td align="left" valign="top">&bull; <a href="fputwc.html#fputwc">fputwc</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write a wide character to a file or stream
  119. </td></tr>
  120. <tr><td align="left" valign="top">&bull; <a href="fputws.html#fputws">fputws</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write a wide character string to a file or stream
  121. </td></tr>
  122. <tr><td align="left" valign="top">&bull; <a href="fread.html#fread">fread</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Read array elements from a file
  123. </td></tr>
  124. <tr><td align="left" valign="top">&bull; <a href="freopen.html#freopen">freopen</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Open a file using an existing file descriptor
  125. </td></tr>
  126. <tr><td align="left" valign="top">&bull; <a href="fseek.html#fseek">fseek</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Set file position
  127. </td></tr>
  128. <tr><td align="left" valign="top">&bull; <a href="_005f_005ffsetlocking.html#g_t_005f_005ffsetlocking">__fsetlocking</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Set or query locking mode on FILE stream
  129. </td></tr>
  130. <tr><td align="left" valign="top">&bull; <a href="fsetpos.html#fsetpos">fsetpos</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Restore position of a stream or file
  131. </td></tr>
  132. <tr><td align="left" valign="top">&bull; <a href="ftell.html#ftell">ftell</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Return position in a stream or file
  133. </td></tr>
  134. <tr><td align="left" valign="top">&bull; <a href="funopen.html#funopen">funopen</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Open a stream with custom callbacks
  135. </td></tr>
  136. <tr><td align="left" valign="top">&bull; <a href="fwide.html#fwide">fwide</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Set and determine the orientation of a FILE stream
  137. </td></tr>
  138. <tr><td align="left" valign="top">&bull; <a href="fwrite.html#fwrite">fwrite</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write array elements from memory to a file or stream
  139. </td></tr>
  140. <tr><td align="left" valign="top">&bull; <a href="getc.html#getc">getc</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get a character from a file or stream (macro)
  141. </td></tr>
  142. <tr><td align="left" valign="top">&bull; <a href="getc_005funlocked.html#getc_005funlocked">getc_unlocked</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get a character from a file or stream (macro)
  143. </td></tr>
  144. <tr><td align="left" valign="top">&bull; <a href="getchar.html#getchar">getchar</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get a character from standard input (macro)
  145. </td></tr>
  146. <tr><td align="left" valign="top">&bull; <a href="getchar_005funlocked.html#getchar_005funlocked">getchar_unlocked</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get a character from standard input (macro)
  147. </td></tr>
  148. <tr><td align="left" valign="top">&bull; <a href="getdelim.html#getdelim">getdelim</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get character string from a file or stream
  149. </td></tr>
  150. <tr><td align="left" valign="top">&bull; <a href="getline.html#getline">getline</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get character string from a file or stream
  151. </td></tr>
  152. <tr><td align="left" valign="top">&bull; <a href="gets.html#gets">gets</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get character string from standard input (obsolete)
  153. </td></tr>
  154. <tr><td align="left" valign="top">&bull; <a href="getw.html#getw">getw</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get a word (int) from a file or stream
  155. </td></tr>
  156. <tr><td align="left" valign="top">&bull; <a href="getwchar.html#getwchar">getwchar</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Get a wide character from standard input
  157. </td></tr>
  158. <tr><td align="left" valign="top">&bull; <a href="mktemp.html#mktemp">mktemp</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Generate unused file name
  159. </td></tr>
  160. <tr><td align="left" valign="top">&bull; <a href="open_005fmemstream.html#open_005fmemstream">open_memstream</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Open a write stream around an arbitrary-length buffer
  161. </td></tr>
  162. <tr><td align="left" valign="top">&bull; <a href="perror.html#perror">perror</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Print an error message on standard error
  163. </td></tr>
  164. <tr><td align="left" valign="top">&bull; <a href="putc.html#putc">putc</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write a character on a stream or file (macro)
  165. </td></tr>
  166. <tr><td align="left" valign="top">&bull; <a href="putc_005funlocked.html#putc_005funlocked">putc_unlocked</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write a character on a stream or file (macro)
  167. </td></tr>
  168. <tr><td align="left" valign="top">&bull; <a href="putchar.html#putchar">putchar</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write a character on standard output (macro)
  169. </td></tr>
  170. <tr><td align="left" valign="top">&bull; <a href="putchar_005funlocked.html#putchar_005funlocked">putchar_unlocked</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write a character on standard output (macro)
  171. </td></tr>
  172. <tr><td align="left" valign="top">&bull; <a href="puts.html#puts">puts</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write a character string on standard output
  173. </td></tr>
  174. <tr><td align="left" valign="top">&bull; <a href="putw.html#putw">putw</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write a word (int) to a file or stream
  175. </td></tr>
  176. <tr><td align="left" valign="top">&bull; <a href="putwchar.html#putwchar">putwchar</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write a wide character to standard output
  177. </td></tr>
  178. <tr><td align="left" valign="top">&bull; <a href="remove.html#remove">remove</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Delete a file&rsquo;s name
  179. </td></tr>
  180. <tr><td align="left" valign="top">&bull; <a href="rename.html#rename">rename</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Rename a file
  181. </td></tr>
  182. <tr><td align="left" valign="top">&bull; <a href="rewind.html#rewind">rewind</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Reinitialize a file or stream
  183. </td></tr>
  184. <tr><td align="left" valign="top">&bull; <a href="setbuf.html#setbuf">setbuf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specify full buffering for a file or stream
  185. </td></tr>
  186. <tr><td align="left" valign="top">&bull; <a href="setbuffer.html#setbuffer">setbuffer</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specify full buffering for a file or stream with size
  187. </td></tr>
  188. <tr><td align="left" valign="top">&bull; <a href="setlinebuf.html#setlinebuf">setlinebuf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specify line buffering for a file or stream
  189. </td></tr>
  190. <tr><td align="left" valign="top">&bull; <a href="setvbuf.html#setvbuf">setvbuf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specify buffering for a file or stream
  191. </td></tr>
  192. <tr><td align="left" valign="top">&bull; <a href="siprintf.html#siprintf">siprintf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write formatted output (integer only)
  193. </td></tr>
  194. <tr><td align="left" valign="top">&bull; <a href="siscanf.html#siscanf">siscanf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Scan and format input (integer only)
  195. </td></tr>
  196. <tr><td align="left" valign="top">&bull; <a href="sprintf.html#sprintf">sprintf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write formatted output
  197. </td></tr>
  198. <tr><td align="left" valign="top">&bull; <a href="sscanf.html#sscanf">sscanf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Scan and format input
  199. </td></tr>
  200. <tr><td align="left" valign="top">&bull; <a href="stdio_005fext.html#stdio_005fext">stdio_ext</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Access internals of FILE structure
  201. </td></tr>
  202. <tr><td align="left" valign="top">&bull; <a href="swprintf.html#swprintf">swprintf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Write formatted wide character output
  203. </td></tr>
  204. <tr><td align="left" valign="top">&bull; <a href="swscanf.html#swscanf">swscanf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Scan and format wide character input
  205. </td></tr>
  206. <tr><td align="left" valign="top">&bull; <a href="tmpfile.html#tmpfile">tmpfile</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Create a temporary file
  207. </td></tr>
  208. <tr><td align="left" valign="top">&bull; <a href="tmpnam.html#tmpnam">tmpnam</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Generate name for a temporary file
  209. </td></tr>
  210. <tr><td align="left" valign="top">&bull; <a href="ungetc.html#ungetc">ungetc</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Push data back into a stream
  211. </td></tr>
  212. <tr><td align="left" valign="top">&bull; <a href="ungetwc.html#ungetwc">ungetwc</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Push wide character data back into a stream
  213. </td></tr>
  214. <tr><td align="left" valign="top">&bull; <a href="vfprintf.html#vfprintf">vfprintf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Format variable argument list
  215. </td></tr>
  216. <tr><td align="left" valign="top">&bull; <a href="vfscanf.html#vfscanf">vfscanf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Scan variable argument list
  217. </td></tr>
  218. <tr><td align="left" valign="top">&bull; <a href="vfwprintf.html#vfwprintf">vfwprintf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Format variable wide character argument list
  219. </td></tr>
  220. <tr><td align="left" valign="top">&bull; <a href="vfwscanf.html#vfwscanf">vfwscanf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Scan and format argument list from wide character input
  221. </td></tr>
  222. <tr><td align="left" valign="top">&bull; <a href="viprintf.html#viprintf">viprintf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Format variable argument list (integer only)
  223. </td></tr>
  224. <tr><td align="left" valign="top">&bull; <a href="viscanf.html#viscanf">viscanf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Scan variable format list (integer only)
  225. </td></tr>
  226. </table>
  227. <hr>
  228. <div class="header">
  229. <p>
  230. Next: <a href="Strings.html#Strings" accesskey="n" rel="next">Strings</a>, Previous: <a href="Ctype.html#Ctype" accesskey="p" rel="prev">Ctype</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Document-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Document-Index.html#Document-Index" title="Index" rel="index">Index</a>]</p>
  231. </div>
  232. </body>
  233. </html>