Author : Tom Torfs
Page : << Previous 23 Next >>
position will be adjusted appropriately. Returns the number of members (not bytes!) successfully read, which may be less than nmemb if an error such as end-of-file occurred.
[*] The result of the multiplication size * nmemb should fit in a size_t, so you can't rely on this feature to get around compiler limits (such as the 64K limit on 16-bit compilers, for example).
FILE *freopen(const char *filename, const char *mode,
FILE *stream);
Opens the file specified by filename in mode mode (see fopen() for details) and associates the specified stream with this file. Any file previously associated with stream is closed. Returns stream when successful or NULL otherwise.
int fscanf(FILE *stream, const char *format, ...);
The fscanf() function is analogous to the scanf() function, except that it reads its input from the specified stream.
int fseek(FILE *stream, long int offset, int whence);
Sets the file position for the specified stream to the specified offset, which is counted in bytes from the beginning of the file if whence equals SEEK_SET, the current file position if whence equals SEEK_CUR or the end of the file if whence equals SEEK_END. For text files, if whence is SEEK_SET offset must be either 0 or a value returned by an earlier call to ftell() on this stream; if whence is SEEK_CUR or SEEK_END offset must be 0. Returns nonzero if the request cannot be satisfied. If the return value is 0, a call to ftell() may be used to make sure the file position has been successfully updated.
int fsetpos(FILE *stream, const fpos_t *pos);
Sets the file position for the specified stream to the position stored in the pos variable by an earlier call to fgetpos() on the same stream. Returns 0 if successful, nonzero otherwise.
long int ftell(FILE *stream);
Returns the current file position for the specified stream. For binary files this is the number of characters from the beginning of the file. For text files, this number is only useful as a parameter to the fseek() function. Returns -1L if unsuccessful.
size_t fwrite(const void *ptr, size_t size, size_t nmemb,
FILE *stream);
Writes upto nmemb elements of the specified size [*] to the specified stream from the array pointed to by ptr. The file position will be adjusted appropriately. Returns the number of members (not bytes!) successfully written, which may be less than nmemb if an error such as end-of-file occurred.
[*] The result of the multiplication size * nmemb should fit in a size_t, so you can't rely on this feature to get around compiler limits (such as the 64K limit on 16-bit compilers, for example).
int getc(FILE *stream);
The getc() function is equivalent to fgetc() except that it may be a macro that can evaluate its argument more than once.
int getchar(void);
The getchar() function is equivalent to getc(stdin).
char *gets(char *s);
Reads characters from stdin into the array pointed to by s, until a newline character is found or an error occurs. Any newline character is removed, and a 0 character is appended. Returns s if successful, NULL otherwise.
WARNING: do not use this function; it does not provide any method of limiting the input to fit inside the array bounds.
void perror(const char *s);
Writes the string pointed to by s (if s is not NULL) to stdout, followed by an appropriate error message depending on the value of errno (the same message as returned by strerror()).
int printf(const char *format, ...);
The printf() function is discussed in 3.3. printf().
int putc(int c, FILE *stream);
The getc() function is equivalent to fputc() except that it may be a macro that can evaluate its argument more than once.
int putchar(int c);
The putchar() function is equivalent to fputc(c, stdout).
int puts(const char *s);
Writes the string pointed to by s to stdout (not including the terminating 0 character) and appends a newline character. Returns a nonnegative value if successful, or EOF otherwise.
int remove(const char *filename);
Removes the specified file. Whether an open file can be removed depends on your system. Returns 0 when successful, nonzero otherwise.
int rename(const char *old, const char *new);
Changes the name of the specified file from the string pointed to by old to that pointed to by new. Whether a file by the latter name is allowed to exist already depends on your system. Returns 0 when successful, nonzero otherwise.
void rewind(FILE *stream);
Sets the file position for the specified stream to the beginning of the file and clears the error indicator for the stream.
int scanf(const char *format, ...);
The scanf() function is discussed in 11.4. Using the standard I/O streams.
void setbuf(FILE *stream, char *buf);
If buf is not NULL, enables full buffering for the stream, using a buffer of size BUFSIZ pointed to by buf. If buf is NULL, disables all buffering for the stream. Should be called after the file has been opened but before any other operations are performed on the stream.
int setvbuf(FILE *stream, char *buf, int mode, size_t size);
The mode parameter determines the buffering mode for the stream: _IOFBF for full buffering, _IOLBF for line buffering and _IONBF for no buffering. The size parameter is the size of the buffer used. If buf is not NULL, the array it points to will be used as buffer. Otherwise, a buffer will be dynamically allocated. Returns 0 on success or nonzero otherwise. Should be called after the file has been opened but before any other operations are performed on the stream.
int sprintf(char *s, const char *format, ...);
The sprintf() function is analogous to the printf() function, except that it writes its output into the specified string.
int sscanf(const char *s, const char *format, ...);
The sscanf() function is analogous to the scanf() function, except that it reads its input from the specified string.
FILE *tmpfile(void);
Creates a temporary file and opens it in "w+b" mode. The file will automatically be removed when closed or at program termination. Returns a valid FILE pointer (stream) when successful, or NULL otherwise.
char *tmpnam(char *s);
Generates a valid, non-existing temporary file name. Every call will generate a different filename, up to TMP_MAX times. If the parameter s is the NULL pointer, the filename will be stored in an internal static object and a pointer to it returned; this also means that subsequent calls to tmpnam() may overwrite its contents. If the parameter is not NULL, it must point to an array of at least L_tmpnam characters; in that case the return value will be the same as the parameter.
int ungetc(int c, FILE *stream);
Pushes the character specified by c (converted to unsigned char) back onto the specified input stream. The pushed back characters will be returned upon subsequent reads on this stream, in the reverse order they were pushed back in. At least 1 character can be pushed back. A successfull call to fseek(), fsetpos() or rewind() on this stream will discard the pushed back characters. Returns the pushed back character if successful, or EOF otherwise.
int vfprintf(FILE *stream, const char *format, va_list arg);
The vfprintf() function is analogous to the vprintf() function, except that it writes its output to the specified stream.
int vprintf(const char *format, va_list arg);
The vprintf() function is discussed in 14.3. Example: a printf() encapsulation.
int vsprintf(char *s, const char *format, va_list arg);
The vsprintf() function is analogous to the vprintf() function, except that it writes its output into the specified string.16.14. stdlib.h (general utilities)
Types
typedef struct {
int quot; /* quotient */
int rem; /* remainder */
} div_t;
Structure returned by the div() function. [*]
typedef struct {
long quot; /* quotient */
long rem; /* remainder */
} ldiv_t;
Structure returned by the ldiv() function. [*]
[*] The order of the members may be different
size_t
Explained in 16.12. stddef.h.
wchar_t
Explained in 16.12. stddef.h.
Macros
EXIT_FAILURE /* unsuccessful termination status */
EXIT_SUCCESS /* successful termination status */
Integer constants for use as argument to the exit() function or as the return value of main().
MB_CUR_MAX
Integer constant representing the maximum number of bytes in a multibyte character in the current locale. Never greater than the value of MB_LEN_MAX (see 16.6. limits.h).
NULL
Explained in 16.12. stddef.h.
RAND_MAX
Integer constant representing the maximum
Page : << Previous 23 Next >>