# <stdio.h> <stdio.h> # `` * * * **`_IOFBF· _IOLBF· _IONBF· BUFSIZ· EOF· FILE· FILENAME_MAX· FOPEN_MAX· L_tmpnam· NULL· SEEK_CUR· SEEK_END· SEEK_SET· TMP_MAX`** **`clearerr· fclose· feof· ferror· fflush· fgetc· fgetpos· fgets· fopen· fpos_t· fprintf· fputc· fputs· fread· freopen· fscanf· fseek· fsetpos· ftell· fwrite· getc· getchar· gets· perror· printf· putc· putchar· puts· remove· rename· rewind· scanf· setbuf· setvbuf· size_t· snprintf· sprintf· sscanf· stderr· stdin· stdout· tmpfile· tmpnam· ungetc· vfprintf· vfscanf· vprintf· vscanf· vsnprintf· vsprintf· vsscanf`** * * * Include the standard header **``** so that you can perform input and output operations on streams and files. /* MACROS */ #define _IOFBF #define _IOLBF #define _IONBF #define BUFSIZ = 256> #define EOF #define FILENAME_MAX 0> #define FOPEN_MAX = 8> #define L_tmpnam 0> #define NULL [0 in C++] #define SEEK_CUR #define SEEK_END #define SEEK_SET #define TMP_MAX = 25> #define stderr #define stdin #define stdout /* TYPES */ typedef o-type FILE; typedef o-type fpos_t; typedef ui-type size_t; /* FUNCTIONS */ void clearerr(FILE *stream); int fclose(FILE *stream); int feof(FILE *stream); int ferror(FILE *stream); int fflush(FILE *stream); FILE *fopen(const char *restrict filename, const char *restrict mode); FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *stream); int remove(const char *filename); int rename(const char *old, const char *new); void rewind(FILE *stream); void setbuf(FILE *restrict stream, char *restrict buf); int setvbuf(FILE *restrict stream, char *restrict buf, int mode, size_t size); FILE *tmpfile(void) char *tmpnam(char *s); int fseek(FILE *stream, long offset, int mode); int fsetpos(FILE *stream, const fpos_t *pos); int fgetpos(FILE *restrict stream, fpos_t *restrict pos); long ftell(FILE *stream); int fgetc(FILE *stream); char *fgets(char *restrict s, int n, FILE *restrict stream); size_t fread(void *restrict ptr, size_t size, size_t nelem, FILE *restrict stream); int getc(FILE *stream); int getchar(void); char *gets(char *s); int ungetc(int c, FILE *stream); int fputc(int c, FILE *stream); int fputs(const char *restrict s, FILE *restrict stream); size_t fwrite(const void *restrict ptr, size_t size, size_t nelem, FILE *restrict stream); void perror(const char *s); int putc(int c, FILE *stream); int putchar(int c); int puts(const char *s); int fscanf(FILE *restrict stream, const char *restrict format, ...); int scanf(const char *restrict format, ...); int sscanf(const char *restrict s, const char *restrict format, ...); int vfscanf(FILE *restrict stream, const char *restrict format, va_list ap); [added with C99] int vscanf(const char *restrict format, va_list ap); [added with C99] int vsscanf(const char *restrict s, const char *restrict format, va_list ap); [added with C99] int fprintf(FILE *restrict stream, const char *restrict format, ...); int printf(const char *restrict format, ...); int snprintf(char *restrict s, size_t n, const char *restrict format, ...); [added with C99] int sprintf(char *restrict s, const char *restrict format, ...); int vfprintf(FILE *restrict stream, const char *restrict format, va_list ap); int vprintf(const char *restrict format, va_list ap); int vsnprintf(char *restrict s, size_t n, const char *restrict format, va_list ap); [added with C99] int vsprintf(char *restrict s, const char *restrict format, va_list ap);Copy to clipboard ## `BUFSIZ` #define BUFSIZ = 256>Copy to clipboard The macro yields the size of the stream buffer used by [`setbuf`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#setbuf). ## `clearerr` void clearerr(FILE *stream);Copy to clipboard The function clears the end-of-file and error indicators for the stream `stream`. ## `EOF` #define EOF Copy to clipboard The macro yields the return value used to signal the end of a stream or to report an error condition. ## `fclose` int fclose(FILE *stream);Copy to clipboard The function closes the file associated with the stream `stream`. It returns zero if successful; otherwise, it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF). `fclose` writes any buffered output to the file, deallocates the stream buffer if it was automatically allocated, and removes the association between the stream and the file. Do not use the value of `stream` in subsequent expressions. ## `feof` int feof(FILE *stream);Copy to clipboard The function returns a nonzero value if the end-of-file indicator is set for the stream `stream`. ## `ferror` int ferror(FILE *stream);Copy to clipboard The function returns a nonzero value if the error indicator is set for the stream `stream`. ## `fflush` int fflush(FILE *stream);Copy to clipboard The function writes any buffered output to the file associated with the stream `stream` and returns zero if successful; otherwise, it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF). If `stream` is a null pointer, `fflush` writes any buffered output to all files opened for output. ## `fgetc` int fgetc(FILE *stream);Copy to clipboard The function reads the next character `c` (if present) from the input stream `stream`, advances the file-position indicator (if defined), and returns `(int)(unsigned char)c`. If the function sets either the end-of-file indicator or the error indicator, it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF). ## `fgetpos` int fgetpos(FILE *restrict stream, fpos_t *restrict pos);Copy to clipboard The function stores the file-position indicator for the stream `stream` in `*pos` and returns zero if successful; otherwise, the function stores a positive value in [`errno`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_errno.html#errno) and returns a nonzero value. ## `fgets` char *fgets(char *restrict s, int n, FILE *restrict stream);Copy to clipboard The function reads characters from the input stream `stream` and stores them in successive elements of the array beginning at `s` and continuing until it stores `n-1` characters, stores an `NL` character, or sets the end-of-file or error indicators. If `fgets` stores any characters, it concludes by storing a null character in the next element of the array. It returns `s` if it stores any characters and it has not set the error indicator for the stream; otherwise, it returns a null pointer. If it sets the error indicator, the array contents are indeterminate. ## `FILE` typedef o-type FILE;Copy to clipboard The type is an object type `o-type` that stores all [control information](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_file.html#Controlling%20Streams) for a stream. The functions [`fopen`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fopen) and [`freopen`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#freopen) allocate all `FILE` objects used by the read and write functions. ## `FILENAME_MAX` #define FILENAME_MAX 0>Copy to clipboard The macro yields the maximum size array of characters that you must provide to hold a [filename](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_over.html#filename). ## `fopen` FILE *fopen(const char *restrict filename, const char *restrict mode);Copy to clipboard The function opens the file with the filename `filename`, associates it with a stream, and returns a pointer to the object controlling the stream. If the open fails, it returns a null pointer. The initial characters of `mode` determine how the program [manipulates](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_file.html#Files%20and%20Streams) the stream and whether it interprets the stream as [text or binary](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_file.html#Text%20and%20Binary%20Streams). The initial characters must be one of the following sequences: - **`"r"`** -- to open an existing text file for reading - **`"w"`** -- to create a text file or to open and truncate an existing text file, for writing - **`"a"`** -- to create a text file or to open an existing text file, for writing. The file-position indicator is positioned at the end of the file before each write - **`"rb"`** -- to open an existing binary file for reading - **`"wb"`** -- to create a binary file or to open and truncate an existing binary file, for writing - **`"ab"`** -- to create a binary file or to open an existing binary file, for writing. The file-position indicator is positioned at the end of the file (possibly after arbitrary null byte padding) before each write - **`"r+"`** -- to open an existing text file for reading and writing - **`"w+"`** -- to create a text file or to open and truncate an existing text file, for reading and writing - **`"a+"`** -- to create a text file or to open an existing text file, for reading and writing. The file-position indicator is positioned at the end of the file before each write - **`"r+b"`** or **`"rb+"`** -- to open an existing binary file for reading and writing - **`"w+b"`** or **`"wb+"`** -- to create a binary file or to open and truncate an existing binary file, for reading and writing - **`"a+b"`** or **`"ab+"`** -- to create a binary file or to open an existing binary file, for reading and writing. The file-position indicator is positioned at the end of the file (possibly after arbitrary null byte padding) before each write If you open a file for both reading and writing, the target environment can open a binary file instead of a text file. If the file is not interactive, the stream is fully buffered. ## `FOPEN_MAX` #define FOPEN_MAX = 8>Copy to clipboard The macro yields the maximum number of files that the target environment permits to be simultaneously open (including [`stderr`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stderr), [`stdin`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stdin), and [`stdout`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stdout)). ## `fpos_t` typedef o-type fpos_t;Copy to clipboard The type is an object type `o-type` of an object that you declare to hold the value of a file-position indicator stored by [`fsetpos`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fsetpos) and accessed by [`fgetpos`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fgetpos). ## `fprintf` int fprintf(FILE *restrict stream, const char *restrict format, ...);Copy to clipboard The function [generates formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_prin.html#Print%20Functions), under the control of the format `format` and any additional arguments, and writes each generated character to the stream `stream`. It returns the number of characters generated, or it returns a negative value if the function sets the error indicator for the stream. ## `fputc` int fputc(int c, FILE *stream);Copy to clipboard The function writes the character `(unsigned char)c` to the output stream `stream`, advances the file-position indicator (if defined), and returns `(int)(unsigned char)c`. If the function sets the error indicator for the stream, it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF). ## `fputs` int fputs(const char *restrict s, FILE *restrict stream);Copy to clipboard The function accesses characters from the [C string](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_over.html#C%20string) `s` and writes them to the output stream `stream`. The function does not write the terminating null character. It returns a nonnegative value if it has not set the error indicator; otherwise, it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF). ## `fread` size_t fread(void *restrict ptr, size_t size, size_t nelem, FILE *restrict stream);Copy to clipboard The function reads characters from the input stream `stream` and stores them in successive elements of the array whose first element has the address `(char *)ptr` until the function stores `size*nelem` characters or sets the end-of-file or error indicator. It returns `n/size`, where `n` is the number of characters it read. If `n` is not a multiple of `size`, the value stored in the last element is indeterminate. If the function sets the error indicator, the file-position indicator is indeterminate. ## `freopen` FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *stream);Copy to clipboard The function closes the file associated with the stream `stream` (as if by calling [`fclose`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fclose)); then it opens the file with the filename `filename` and associates the file with the stream `stream` (as if by calling `fopen(filename, mode)`). It returns `stream` if the open is successful; otherwise, it returns a null pointer. ## `fscanf` int fscanf(FILE *restrict stream, const char *restrict format, ...);Copy to clipboard The function [scans formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_scan.html#Scan%20Functions), under the control of the format `format` and any additional arguments. It obtains each scanned character from the stream `stream`. It returns the number of input items matched and assigned, or it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF) if the function does not store values before it sets the end-of-file or error indicator for the stream. ## `fseek` int fseek(FILE *stream, long offset, int mode);Copy to clipboard The function sets the file-position indicator for the stream `stream` (as specified by `offset` and `mode`), clears the end-of-file indicator for the stream, and returns zero if successful. For a [binary stream](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_file.html#binary%20stream), `offset` is a signed offset in bytes: - If `mode` has the value [`SEEK_SET`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#SEEK_SET), `fseek` adds `offset` to the file-position indicator for the beginning of the file. - If `mode` has the value [`SEEK_CUR`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#SEEK_CUR), `fseek` adds `offset` to the current file-position indicator. - If `mode` has the value [`SEEK_END`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#SEEK_END), `fseek` adds `offset` to the file-position indicator for the end of the file (possibly after arbitrary null character padding). `fseek` sets the file-position indicator to the result of this addition. For a [text stream](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_file.html#text%20stream): - If `mode` has the value [`SEEK_SET`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#SEEK_SET), `fseek` sets the file-position indicator to the value encoded in `offset`, which is either a value returned by an earlier successful call to [`ftell`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#ftell) or zero to indicate the beginning of the file. - If `mode` has the value [`SEEK_CUR`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#SEEK_CUR) and `offset` is zero, `fseek` leaves the file-position indicator at its current value. - If `mode` has the value [`SEEK_END`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#SEEK_END) and `offset` is zero, `fseek` sets the file-position indicator to indicate the end of the file. The function defines no other combination of argument values. ## `fsetpos` int fsetpos(FILE *stream, const fpos_t *pos);Copy to clipboard The function sets the file-position indicator for the stream `stream` to the value stored in `*pos`, clears the end-of-file indicator for the stream, and returns zero if successful. Otherwise, the function stores a positive value in [`errno`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_errno.html#errno) and returns a nonzero value. ## `ftell` long ftell(FILE *stream);Copy to clipboard The function returns an encoded form of the file-position indicator for the stream `stream` or stores a positive value in [`errno`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_errno.html#errno) and returns the value -1. For a binary file, a successful return value gives the number of bytes from the beginning of the file. For a text file, target environments can vary on the representation and range of encoded file-position indicator values. ## `fwrite` size_t fwrite(const void *restrict ptr, size_t size, size_t nelem, FILE *stream);Copy to clipboard The function writes characters to the output stream `stream`, accessing values from successive elements of the array whose first element has the address `(char *)ptr` until the function writes `size*nelem` characters or sets the error indicator. It returns `n/size`, where `n` is the number of characters it wrote. If the function sets the error indicator, the file-position indicator is indeterminate. ## `getc` int getc(FILE *stream);Copy to clipboard The function has the same effect as `fgetc(stream)` except that a macro version of `getc` can evaluate `stream` more than once. ## `getchar` int getchar(void);Copy to clipboard The function has the same effect as `fgetc(stdin)`, reading a character from the stream [`stdin`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stdin) ## `gets` char *gets(char *s);Copy to clipboard The function reads characters from the stream [`stdin`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stdin) and stores them in successive elements of the array whose first element has the address `s` until the function reads an `NL` character (which is not stored) or sets the end-of-file or error indicator. If `gets` reads any characters, it concludes by storing a null character in the next element of the array. It returns `s` if it reads any characters and has not set the error indicator for the stream; otherwise, it returns a null pointer. If it sets the error indicator, the array contents are indeterminate. The number of characters that `gets` reads and stores cannot be limited. Use [`fgets`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fgets) instead. ## `_IOFBF` #define _IOFBF Copy to clipboard The macro yields the value of the `mode` argument to [`setvbuf`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#setvbuf) to indicate **full buffering**. (Flush the stream buffer only when it fills.) ## `_IOLBF` #define _IOLBF Copy to clipboard The macro yields the value of the `mode` argument to [`setvbuf`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#setvbuf) to indicate **line buffering**. (Flush the stream buffer at the end of a [text line](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_file.html#text%20lines).) ## `_IONBF` #define _IONBF Copy to clipboard The macro yields the value of the `mode` argument to [`setvbuf`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#setvbuf) to indicate **no buffering**. (Flush the stream buffer at the end of each write operation.) ## `L_tmpnam` #define L_tmpnam 0>Copy to clipboard The macro yields the number of characters that the target environment requires for representing temporary filenames created by [`tmpnam`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#tmpnam). ## `NULL` #define NULL [0 in C++]Copy to clipboard The macro yields a null pointer constant that is usable as an [address constant expression](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_express.html#address%20constant%20expression). ## `perror` void perror(const char *s);Copy to clipboard The function writes a line of text to the stream [`stderr`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stderr). If `s` is not a null pointer, the function first writes the [C string](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_over.html#C%20string) `s` (as if by calling `fputs(s, stderr)`), followed by a colon (`:`) and a `space`. It then writes the same message [C string](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_over.html#C%20string) that is returned by `strerror(errno)`, converting the value stored in [`errno`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_errno.html#errno), followed by an `NL`. ## `printf` int printf(const char *restrict format, ...);Copy to clipboard The function [generates formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_prin.html#Print%20Functions), under the control of the format `format` and any additional arguments, and writes each generated character to the stream [`stdout`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stdout). It returns the number of characters generated, or it returns a negative value if the function sets the error indicator for the stream. ## `putc` int putc(int c, FILE *stream);Copy to clipboard The function has the same effect as `fputc(c, stream)` except that a macro version of `putc` can evaluate `stream` more than once. ## `putchar` int putchar(int c);Copy to clipboard The function has the same effect as `fputc(c, stdout)`, writing a character to the stream [`stdout`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stdout). ## `puts` int puts(const char *s);Copy to clipboard The function accesses characters from the [C string](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_over.html#C%20string) `s` and writes them to the stream [`stdout`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stdout). The function writes an `NL` character to the stream in place of the terminating null character. It returns a nonnegative value if it has not set the error indicator; otherwise, it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF). ## `remove` int remove(const char *filename);Copy to clipboard The function removes the file with the filename `filename` and returns zero if successful. If the file is open when you remove it, the result is implementation defined. After you remove it, you cannot open it as an existing file. ## `rename` int rename(const char *old, const char *new);Copy to clipboard The function renames the file with the filename `old` to have the filename `new` and returns zero if successful. If a file with the filename `new` already exists, the result is implementation defined. After you rename it, you cannot open the file with the filename `old`. ## `rewind` void rewind(FILE *stream);Copy to clipboard The function calls `fseek(stream, 0L, SEEK_SET)` and then clears the error indicator for the stream `stream`. ## `scanf` int scanf(const char *restrict format, ...);Copy to clipboard The function [scans formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_scan.html#Scan%20Functions), under the control of the format `format` and any additional arguments. It obtains each scanned character from the stream [`stdin`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stdin). It returns the number of input items matched and assigned, or it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF) if the function does not store values before it sets the end-of-file or error indicators for the stream. ## `SEEK_CUR` #define SEEK_CUR Copy to clipboard The macro yields the value of the `mode` argument to [`fseek`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fseek) to indicate seeking relative to the current file-position indicator. ## `SEEK_END` #define SEEK_END Copy to clipboard The macro yields the value of the `mode` argument to [`fseek`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fseek) to indicate seeking relative to the end of the file. ## `SEEK_SET` #define SEEK_SET Copy to clipboard The macro yields the value of the `mode` argument to [`fseek`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fseek) to indicate seeking relative to the beginning of the file. ## `setbuf` void setbuf(FILE *restrict stream, char *restrict buf);Copy to clipboard If `buf` is not a null pointer, the function calls `setvbuf(stream, buf, __IOFBF, BUFSIZ)`, specifying full buffering with [`_IOFBF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#_IOFBF) and a buffer size of [`BUFSIZ`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#BUFSIZ) characters. Otherwise, the function calls `setvbuf(stream, 0, _IONBF, BUFSIZ)`, specifying no buffering with [`_IONBF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#_IONBF). ## `setvbuf` int setvbuf(FILE *restrict stream, char *restrict buf, int mode, size_t size);Copy to clipboard The function sets the buffering mode for the stream `stream` according to `buf`, `mode`, and `size`. It returns zero if successful. If `buf` is not a null pointer, then `buf` is the address of the first element of an array of *char* of size `size` that can be used as the stream buffer. Otherwise, `setvbuf` can allocate a stream buffer that is freed when the file is closed. For `mode` you must supply one of the following values: - **[`_IOFBF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#_IOFBF)** -- to indicate full buffering - **[`_IOLBF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#_IOLBF)** -- to indicate line buffering - **[`_IONBF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#_IONBF)** -- to indicate no buffering You must call `setvbuf` after you call [`fopen`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fopen) to associate a file with that stream and before you call a library function that performs any other operation on the stream. ## `size_t` typedef ui-type size_t;Copy to clipboard The type is the unsigned integer type `ui-type` of an object that you declare to store the result of the [*sizeof*](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_express.html#sizeof%20operator) operator. ## `snprintf` int snprintf(char *restrict s, size_t n, const char *restrict format, ...); [added with C99]Copy to clipboard The function [generates formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_prin.html#Print%20Functions), under the control of the format `format` and any additional arguments, and stores each generated character in successive locations of the array object whose first element has the address `s`. If `n` is zero, it stores no characters. Otherwise, the function stores up to `n - 1` characters and concludes by storing a null character in the next location of the array. It returns the number of characters generated -- not including the null character. ## `sprintf` int sprintf(char *restrict s, const char *restrict format, ...);Copy to clipboard The function [generates formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_prin.html#Print%20Functions), under the control of the format `format` and any additional arguments, and stores each generated character in successive locations of the array object whose first element has the address `s`. The function concludes by storing a null character in the next location of the array. It returns the number of characters generated -- not including the null character. ## `sscanf` int sscanf(const char *restrict s, const char *restrict format, ...);Copy to clipboard The function [scans formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_scan.html#Scan%20Functions), under the control of the format `format` and any additional arguments. It accesses each scanned character from successive locations of the array object whose first element has the address `s`. It returns the number of items matched and assigned, or it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF) if the function does not store values before it accesses a null character from the array. ## `stderr` #define stderr Copy to clipboard The macro yields a pointer to the object that controls the standard error output stream. ## `stdin` #define stdin Copy to clipboard The macro yields a pointer to the object that controls the standard input stream. ## `stdout` #define stdout Copy to clipboard The macro yields a pointer to the object that controls the standard output stream. ## `tmpfile` FILE *tmpfile(void)Copy to clipboard The function creates a temporary binary file with the filename `temp-name` and then has the same effect as calling `fopen(temp-name, "wb+")`. The file `temp-name` is removed when the program closes it, either by calling [`fclose`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fclose) explicitly or at normal program termination. The filename `temp-name` does not conflict with any filenames that you create. If the open is successful, the function returns a pointer to the object controlling the stream; otherwise, it returns a null pointer. ## `TMP_MAX` #define TMP_MAX = 25>Copy to clipboard The macro yields the minimum number of distinct filenames created by the function [`tmpnam`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#tmpnam). ## `tmpnam` char *tmpnam(char *s);Copy to clipboard The function creates a unique filename `temp-name` and returns a pointer to the filename. If `s` is not a null pointer, then `s` must be the address of the first element of an array at least of size [`L_tmpnam`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#L_tmpnam). The function stores `temp-name` in the array and returns `s`. Otherwise, if `s` is a null pointer, the function stores `temp-name` in a static-duration array and returns the address of its first element. Subsequent calls to `tmpnam` can alter the values stored in this array. The function returns unique filenames for each of the first [`TMP_MAX`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#TMP_MAX) times it is called, after which its behavior is implementation defined. The filename `temp-name` does not conflict with any filenames that you create. ## `ungetc` int ungetc(int c, FILE *stream);Copy to clipboard If `c` is not equal to [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF), the function stores `(unsigned char)c` in the object whose address is `stream` and clears the end-of-file indicator. If `c` equals [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF) or the store cannot occur, the function returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF); otherwise, it returns `(unsigned char)c`. A subsequent library function call that reads a character from the stream `stream` obtains this stored value, which is then forgotten. Thus, you can effectively **push back** a character to a stream after reading a character. (You need not push back the same character that you read.) An implementation can let you push back additional characters before you read the first one. You read the characters in reverse order of pushing them back to the stream. You cannot portably: - push back more than one character - push back a character if the file-position indicator is at the beginning of the file - Call [`ftell`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#ftell) for a text file that has a character currently pushed back A call to the functions [`fseek`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fseek), [`fsetpos`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#fsetpos), or [`rewind`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#rewind) for the stream causes the stream to forget any pushed-back characters. For a binary stream, the file-position indicator is decremented for each character that is pushed back. ## `vfprintf` int vfprintf(FILE *restrict stream, const char *restrict format, va_list ap);Copy to clipboard The function [generates formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_prin.html#Print%20Functions), under the control of the format `format` and any additional arguments, and writes each generated character to the stream `stream`. It returns the number of characters generated, or it returns a negative value if the function sets the error indicator for the stream. The function accesses additional arguments by using the context information designated by `ap`. The program must execute the macro [`va_start`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_start) before it calls the function, and then execute the macro [`va_end`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_end) after the function returns. ## `vfscanf` int vfscanf(FILE *restrict stream, const char *restrict format, va_list ap); [added with C99]Copy to clipboard The function [scans formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_scan.html#Scan%20Functions), under the control of the format `format` and any additional arguments. It obtains each scanned character from the stream `stream`. It returns the number of input items matched and assigned, or it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF) if the function does not store values before it sets the end-of-file or error indicator for the stream. The function accesses additional arguments by using the context information designated by `ap`. The program must execute the macro [`va_start`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_start) before it calls the function, and then execute the macro [`va_end`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_end) after the function returns. ## `vprintf` int vprintf(const char *restrict format, va_list ap);Copy to clipboard The function [generates formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_prin.html#Print%20Functions), under the control of the format `format` and any additional arguments, and writes each generated character to the stream [`stdout`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stdout). It returns the number of characters generated, or a negative value if the function sets the error indicator for the stream. The function accesses additional arguments by using the context information designated by `ap`. The program must execute the macro [`va_start`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_start) before it calls the function, and then execute the macro [`va_end`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_end) after the function returns. ## `vscanf` int vscanf(const char *restrict format, va_list ap); [added with C99]Copy to clipboard The function [scans formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_scan.html#Scan%20Functions), under the control of the format `format` and any additional arguments. It obtains each scanned character from the stream [`stdin`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#stdin). It returns the number of input items matched and assigned, or it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF) if the function does not store values before it sets the end-of-file or error indicators for the stream. The function accesses additional arguments by using the context information designated by `ap`. The program must execute the macro [`va_start`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_start) before it calls the function, and then execute the macro [`va_end`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_end) after the function returns. ## `vsnprintf` int vsnprintf(char *restrict s, size_t n, const char *restrict format, va_list ap); [added with C99]Copy to clipboard The function [generates formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_prin.html#Print%20Functions), under the control of the format `format` and any additional arguments, and stores each generated character in successive locations of the array object whose first element has the address `s`. If `n` is zero, it stores no characters. Otherwise, the function stores up to `n - 1` characters and concludes by storing a null character in the next location of the array. It returns the number of characters generated -- not including the null character. The function accesses additional arguments by using the context information designated by `ap`. The program must execute the macro [`va_start`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_start) before it calls the function, and then execute the macro [`va_end`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_end) after the function returns. ## `vsprintf` int vsprintf(char *restrict s, const char *restrict format, va_list ap);Copy to clipboard The function [generates formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_prin.html#Print%20Functions), under the control of the format `format` and any additional arguments, and stores each generated character in successive locations of the array object whose first element has the address `s`. The function concludes by storing a null character in the next location of the array. It returns the number of characters generated -- not including the null character. The function accesses additional arguments by using the context information designated by `ap`. The program must execute the macro [`va_start`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_start) before it calls the function, and then execute the macro [`va_end`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_end) after the function returns. ## `vsscanf` int vsscanf(const char *restrict s, const char *restrict format, va_list ap); [added with C99]Copy to clipboard The function [scans formatted text](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_lib_scan.html#Scan%20Functions), under the control of the format `format` and any additional arguments. It accesses each scanned character from successive locations of the array object whose first element has the address `s`. It returns the number of items matched and assigned, or it returns [`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdio.html#EOF) if the function does not store values before it accesses a null character from the array. The function accesses additional arguments by using the context information designated by `ap`. The program must execute the macro [`va_start`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_start) before it calls the function, and then execute the macro [`va_end`](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_stdarg.html#va_end) after the function returns. * * * See also the **[Table of Contents](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_index.html#Table%20of%20Contents)** and the **[Index](https://docs.qualcomm.com/doc/80-N3040-23/topic/_c_index.html)**. *[Copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/c_crit_pjp.html) © 1992-2006by P.J. Plauger and Jim Brodie. All rights reserved.* Last Published: Oct 06, 2026 Previous Topic Next Topic