2000-02-18 03:39:52 +08:00
|
|
|
@node Stdio
|
2007-07-14 01:07:28 +08:00
|
|
|
@chapter Input and Output (@file{stdio.h})
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
This chapter comprises functions to manage files
|
|
|
|
or other input/output streams. Among these functions are subroutines
|
2007-07-14 01:07:28 +08:00
|
|
|
to generate or scan strings according to specifications from a format string.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
The underlying facilities for input and output depend on the host
|
|
|
|
system, but these functions provide a uniform interface.
|
|
|
|
|
|
|
|
The corresponding declarations are in @file{stdio.h}.
|
|
|
|
|
|
|
|
The reentrant versions of these functions use macros
|
|
|
|
|
|
|
|
@example
|
|
|
|
_stdin_r(@var{reent})
|
|
|
|
_stdout_r(@var{reent})
|
|
|
|
_stderr_r(@var{reent})
|
|
|
|
@end example
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
instead of the globals @code{stdin}, @code{stdout}, and
|
|
|
|
@code{stderr}. The argument <[reent]> is a pointer to a reentrancy
|
|
|
|
structure.
|
2007-07-14 01:07:28 +08:00
|
|
|
|
|
|
|
@menu
|
2000-02-18 03:39:52 +08:00
|
|
|
* clearerr:: Clear file or stream error indicator
|
2007-07-14 01:07:28 +08:00
|
|
|
* diprintf:: Print to a file descriptor (integer only)
|
2005-10-12 07:59:32 +08:00
|
|
|
* dprintf:: Print to a file descriptor
|
2000-02-18 03:39:52 +08:00
|
|
|
* fclose:: Close a file
|
2004-09-17 05:15:14 +08:00
|
|
|
* fcloseall:: Close all files
|
2007-07-14 01:07:28 +08:00
|
|
|
* fdopen:: Turn an open file into a stream
|
2000-02-18 03:39:52 +08:00
|
|
|
* feof:: Test for end of file
|
|
|
|
* ferror:: Test whether read/write error has occurred
|
|
|
|
* fflush:: Flush buffered file output
|
|
|
|
* fgetc:: Get a character from a file or stream
|
|
|
|
* fgetpos:: Record position in a stream or file
|
|
|
|
* fgets:: Get character string from a file or stream
|
2004-09-17 05:15:14 +08:00
|
|
|
* fileno:: Get file descriptor associated with stream
|
2007-08-03 04:23:06 +08:00
|
|
|
* fmemopen:: Open a stream around a fixed-length buffer
|
2000-02-18 03:39:52 +08:00
|
|
|
* fopen:: Open a file
|
2007-07-14 01:07:28 +08:00
|
|
|
* fopencookie:: Open a stream with custom callbacks
|
2000-02-18 03:39:52 +08:00
|
|
|
* fputc:: Write a character on a stream or file
|
|
|
|
* fputs:: Write a character string in a file or stream
|
|
|
|
* fread:: Read array elements from a file
|
|
|
|
* freopen:: Open a file using an existing file descriptor
|
|
|
|
* fseek:: Set file position
|
|
|
|
* fsetpos:: Restore position of a stream or file
|
|
|
|
* ftell:: Return position in a stream or file
|
2007-07-14 01:07:28 +08:00
|
|
|
* funopen:: Open a stream with custom callbacks
|
2000-02-18 03:39:52 +08:00
|
|
|
* fwrite:: Write array elements from memory to a file or stream
|
|
|
|
* getc:: Get a character from a file or stream (macro)
|
2004-09-17 05:15:14 +08:00
|
|
|
* getc_unlocked:: Get a character from a file or stream (macro)
|
2000-02-18 03:39:52 +08:00
|
|
|
* getchar:: Get a character from standard input (macro)
|
2004-09-17 05:15:14 +08:00
|
|
|
* getchar_unlocked:: Get a character from standard input (macro)
|
|
|
|
* getdelim:: Get character string from a file or stream
|
|
|
|
* getline:: Get character string from a file or stream
|
2000-02-18 03:39:52 +08:00
|
|
|
* gets:: Get character string from standard input (obsolete)
|
2000-03-08 11:42:25 +08:00
|
|
|
* getw:: Get a word (int) from a file or stream
|
2000-02-18 03:39:52 +08:00
|
|
|
* mktemp:: Generate unused file name
|
2007-08-03 04:23:06 +08:00
|
|
|
* open_memstream:: Open a write stream around an arbitrary-length buffer
|
2000-02-18 03:39:52 +08:00
|
|
|
* perror:: Print an error message on standard error
|
|
|
|
* putc:: Write a character on a stream or file (macro)
|
2004-09-17 05:15:14 +08:00
|
|
|
* putc_unlocked:: Write a character on a stream or file (macro)
|
2000-02-18 03:39:52 +08:00
|
|
|
* putchar:: Write a character on standard output (macro)
|
2004-09-17 05:15:14 +08:00
|
|
|
* putchar_unlocked:: Write a character on standard output (macro)
|
2000-02-18 03:39:52 +08:00
|
|
|
* puts:: Write a character string on standard output
|
2000-03-08 11:42:25 +08:00
|
|
|
* putw:: Write a word (int) to a file or stream
|
2000-02-18 03:39:52 +08:00
|
|
|
* remove:: Delete a file's name
|
|
|
|
* rename:: Rename a file
|
|
|
|
* rewind:: Reinitialize a file or stream
|
|
|
|
* setbuf:: Specify full buffering for a file or stream
|
2004-09-17 05:15:14 +08:00
|
|
|
* setbuffer:: Specify full buffering for a file or stream with size
|
|
|
|
* setlinebuf:: Specify line buffering for a file or stream
|
2000-02-18 03:39:52 +08:00
|
|
|
* setvbuf:: Specify buffering for a file or stream
|
2007-07-14 01:07:28 +08:00
|
|
|
* siprintf:: Write formatted output (integer only)
|
|
|
|
* siscanf:: Scan and format input (integer only)
|
|
|
|
* sprintf:: Write formatted output
|
|
|
|
* sscanf:: Scan and format input
|
2000-02-18 03:39:52 +08:00
|
|
|
* tmpfile:: Create a temporary file
|
|
|
|
* tmpnam:: Generate name for a temporary file
|
2007-07-14 01:07:28 +08:00
|
|
|
* ungetc:: Push data back into a stream
|
|
|
|
* vfprintf:: Format variable argument list
|
|
|
|
* vfscanf:: Scan variable argument list
|
|
|
|
* viprintf:: Format variable argument list (integer only)
|
|
|
|
* viscanf:: Scan variable format list (integer only)
|
|
|
|
@end menu
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/clearerr.def
|
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/diprintf.def
|
|
|
|
|
2005-10-12 07:59:32 +08:00
|
|
|
@page
|
|
|
|
@include stdio/dprintf.def
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
|
|
|
@include stdio/fclose.def
|
|
|
|
|
2004-09-17 05:15:14 +08:00
|
|
|
@page
|
|
|
|
@include stdio/fcloseall.def
|
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/fdopen.def
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
|
|
|
@include stdio/feof.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/ferror.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/fflush.def
|
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/fgetc.def
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/fgetpos.def
|
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/fgets.def
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2004-09-17 05:15:14 +08:00
|
|
|
@page
|
|
|
|
@include stdio/fileno.def
|
|
|
|
|
2007-08-03 04:23:06 +08:00
|
|
|
@page
|
|
|
|
@include stdio/fmemopen.def
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
|
|
|
@include stdio/fopen.def
|
|
|
|
|
|
|
|
@page
|
2007-07-14 01:07:28 +08:00
|
|
|
@include stdio/fopencookie.def
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/fputc.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/fputs.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/fread.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/freopen.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/fseek.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/fsetpos.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/ftell.def
|
|
|
|
|
2007-07-19 11:42:21 +08:00
|
|
|
@page
|
|
|
|
@include stdio/funopen.def
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
|
|
|
@include stdio/fwrite.def
|
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/getc.def
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2004-09-17 05:15:14 +08:00
|
|
|
@page
|
|
|
|
@include stdio/getc_u.def
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
2007-07-14 01:07:28 +08:00
|
|
|
@include stdio/getchar.def
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2004-09-17 05:15:14 +08:00
|
|
|
@page
|
|
|
|
@include stdio/getchar_u.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/getdelim.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/getline.def
|
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
2000-02-18 03:39:52 +08:00
|
|
|
@include stdio/gets.def
|
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/getw.def
|
2000-03-08 11:42:25 +08:00
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
|
|
|
@include stdio/mktemp.def
|
|
|
|
|
2007-08-03 04:23:06 +08:00
|
|
|
@page
|
|
|
|
@include stdio/open_memstream.def
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
|
|
|
@include stdio/perror.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/putc.def
|
|
|
|
|
2004-09-17 05:15:14 +08:00
|
|
|
@page
|
|
|
|
@include stdio/putc_u.def
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
|
|
|
@include stdio/putchar.def
|
|
|
|
|
2004-09-17 05:15:14 +08:00
|
|
|
@page
|
|
|
|
@include stdio/putchar_u.def
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
|
|
|
@include stdio/puts.def
|
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/putw.def
|
2000-03-08 11:42:25 +08:00
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
|
|
|
@include stdio/remove.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/rename.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/rewind.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/setbuf.def
|
|
|
|
|
2004-09-17 05:15:14 +08:00
|
|
|
@page
|
|
|
|
@include stdio/setbuffer.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/setlinebuf.def
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
|
|
|
@include stdio/setvbuf.def
|
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/siprintf.def
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
@page
|
2007-07-14 01:07:28 +08:00
|
|
|
@include stdio/siscanf.def
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/sprintf.def
|
2004-11-24 08:45:41 +08:00
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/sscanf.def
|
2004-11-24 08:45:41 +08:00
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
@page
|
|
|
|
@include stdio/tmpfile.def
|
|
|
|
|
|
|
|
@page
|
|
|
|
@include stdio/tmpnam.def
|
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/ungetc.def
|
2002-07-18 07:25:44 +08:00
|
|
|
|
2004-09-17 05:15:14 +08:00
|
|
|
@page
|
2007-07-14 01:07:28 +08:00
|
|
|
@include stdio/vfprintf.def
|
2004-11-24 08:45:41 +08:00
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/vfscanf.def
|
2004-11-24 08:45:41 +08:00
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/viprintf.def
|
2004-11-24 08:45:41 +08:00
|
|
|
|
2007-07-14 01:07:28 +08:00
|
|
|
@page
|
|
|
|
@include stdio/viscanf.def
|