STDIO.H(7) Miscellaneous Information Manual STDIO.H(7)

stdio.hstandard buffered input/output

#include <stdio.h>

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 (“POSIX.1”), xsh_chap02_02(3)) to enable the visibility of these symbols in this header.

The <stdio.h> header shall define the following macros as positive integer constant expressions:

Size of <stdio.h> buffers.
Input/output fully buffered.
Input/output line buffered.
Input/output unbuffered.
[CX] Maximum size of character array to hold () output.
Maximum size of character array to hold tmpnam () output.
Seek relative to current position.
Seek relative to end-of-file.
Seek relative to start-of-file.

The following macros shall be defined as positive integer constant expressions which denote implementation limits:

Maximum size in bytes of the longest filename string that the implementation guarantees can be opened.
Number of streams which the implementation guarantees can be open simultaneously. The value is at least eight.
Minimum number of unique filenames generated by tmpnam () . Maximum number of times an application can call tmpnam () reliably. The value of {TMP_MAX} is at least 25. [XSI] On XSI-conformant systems, the value of {TMP_MAX} is at least 10000.

The following macro name shall be defined as a negative integer constant expression:

End-of-file return value.

The following macro name shall be defined as a null pointer constant:

Null pointer.

The following macro name shall be defined as a string constant:

[XSI] Default directory prefix for () .

The following shall be defined as expressions of type "pointer to FILE " that point to the FILE objects associated, respectively, with the standard error, input, and output streams:

Standard error output stream.
Standard input stream.
Standard output stream.

The following data types shall be defined through :

A structure containing information about a file.
A non-array type containing all information needed to specify uniquely every position within a file.
[XSI] As described in <stdarg.h> .
As described in <stddef.h> .

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

void     clearerr(FILE *);
[CX]
char    *ctermid(char *);

int      fclose(FILE *);
[CX]
FILE    *fdopen(int, const char *);

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);
[CX]
int      fileno(FILE *);

[TSF]
void     flockfile(FILE *);

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);
[CX]
int      fseeko(FILE *, off_t, int);

int      fsetpos(FILE *, const fpos_t *);
long     ftell(FILE *);
[CX]
off_t    ftello(FILE *);

[TSF]
int      ftrylockfile(FILE *);
void     funlockfile(FILE *);

size_t   fwrite(const void *restrict, size_t, size_t, FILE *restrict);
int      getc(FILE *);
int      getchar(void);
[TSF]
int      getc_unlocked(FILE *);
int      getchar_unlocked(void);

char    *gets(char *);
[CX]
int      pclose(FILE *);

void     perror(const char *);
[CX]
FILE    *popen(const char *, const char *);

int      printf(const char *restrict, ...);
int      putc(int, FILE *);
int      putchar(int);
[TSF]
int      putc_unlocked(int, FILE *);
int      putchar_unlocked(int);

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 ...);
[XSI]
char    *tempnam(const char *, const char *);

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);

Inclusion of the <stdio.h> header may also make visible all symbols from <stddef.h>.

None.

None.

None.

<stdarg.h> , <stddef.h> , <sys/types.h> , the System Interfaces volume of IEEE Std 1003.1-2001 (“POSIX.1”), clearerr(3), ctermid(3), fclose(3), fdopen(3), fgetc(3), fgetpos(3), ferror(3), feof(3), fflush(3), fgets(3), fileno(3), flockfile(3), fopen(3), fputc(3), fputs(3), fread(3), freopen(3), fseek(3), fsetpos(3), ftell(3), fwrite(3), getc(3), getc_unlocked(3), getwchar(3), getchar(3), getopt (), gets(3), pclose(3), perror(3), popen(3), printf(3), putc(3), putchar(3), puts(3), putwchar(3), remove(3), rename(3), rewind(3), scanf(3), setbuf(3), setvbuf(3), sscanf(3), stdin, system(3), tempnam(3), tmpfile(3), tmpnam(3), ungetc(3), vfscanf(3), vscanf(3), vprintf(3), vsscanf(3)

First released in Issue 1. Derived from Issue 1 of the SVID.

The DESCRIPTION is updated for alignment with the POSIX Threads Extension.

Large File System extensions are added.

The constant L_cuserid and the external variables optarg, opterr, optind, and optopt are marked as extensions and LEGACY.

The cuserid () and getopt () functions are marked LEGACY.

The constant L_cuserid and the external variables optarg, opterr, optind, and optopt are removed as they were previously marked LEGACY.

The cuserid (), getopt (), and () functions are removed as they were previously marked LEGACY.

Several functions are marked as part of the Thread-Safe Functions option.

This reference page is updated to align with the ISO/IEC 9899:1999 (“ISO C99”) standard. Note that the description of the fpos_t type is now explicitly updated to exclude array types.

Extensions beyond the ISO C standard are marked.

footer end

December 6, 2001 posix.fail