United States |
|
|
||
9.9 Signal Handling (<signal.h>)The <signal.h> header file declares a type and two functions and defines several macros for handling exception conditions that might be reported during program execution. The integral type of an object that can be accessed as an atomic entity, even in the presence of asynchronous interrupts.
Expand to constant expressions with distinct values that have a type compatible with the second argument to, and the return value of, the signal function, and whose value compares unequal to the address of any declarable function. void (*signal(int sig, void (*handler) (int))) (int); Determines how subsequent signals are handled. Signals are handled in the following way: Sends the signal sig to the executing program. The raise function returns 0 if successful and nonzero if unsuccessful. 9.10 Variable Arguments (<stdarg.h>)The <stdarg.h> header file declares a type and defines three macros for advancing through a list of function arguments of varying number and type. A type suitable for holding information needed by the macros va_start , va_arg , and va_end . void va_start(va_list ap, parmN); Initializes ap for subsequent use by va_arg and va_end . The va_start macro must be invoked before any access to the unnamed arguments. type va_arg(va_list ap, type); Expands to an expression that has the type and value of the next argument in the call. The parameter ap is the same as the va_list ap that was initialized by va_start . Each invocation of va_arg modifies ap so that the values of successive arguments are returned in turn. The parameter type is a type name specified such that the type of a pointer to an object that has the specified type can be obtained by postfixing an asterisk (*) to type. The behavior is undefined if there is no actual next argument, or if type is not compatible with the type of the next actual argument (as promoted according to the default argument promotions). Facilitates a normal return from the function whose variable argument list was referred to by the expansion of va_start that initialized the va_list ap object. The va_end macro can modify ap so that it can no longer be used (without an intervening invocation of va_start ). If there is no corresponding invocation of va_start or if va_end is not invoked before the return, the behavior is undefined. The va_end macro returns no value. 9.11 Boolean Type and Values(<stdbool.h>)The <stdbool.h> header file defines four macros. bool Expands to _Bool .
true
Suitable for use in #if preprocessing directives. 9.12 Common Definitions (<stddef.h>)The <stddef.h> header file defines several types and macros, some of which are also defined in other header files. A signed integral type of the result of subtracting two pointers. An unsigned integral type of the result of the sizeof operator. An integral type whose range of values can represent distinct codes for all members of the largest extended character set specified among the supported locales. NULL Expands to an implementation-defined null pointer constant. offsetof(type, member-designator) Expands to an integral constant expression that has type size_t and a value that is the offset, in bytes, to the structure member (specified by member-designator) from the beginning of its structure (specified by type). The member-designator is such that the expression &(t.member-designator) evaluates to an address constant given the following: 9.13 Standard Input/Output (<stdio.h>)The <stdio.h> header file declares three types, several macros, and many functions for performing text input and output. A text stream consists of a sequence of lines; each line ends with a new-line character. An unsigned integral type of the result of the sizeof operator. An object type capable of recording all the information needed to control a data stream, including its file-position indicator, a pointer to its associated buffer (if any), an error indicator that records whether a read/write error occurred, and an end-of-file indicator that records whether the end of the file has been reached. An object capable of recording all the information needed to uniquely specify every position within a file. Expands to an implementation-defined null pointer constant. Expand to integral constant expressions with distinct values, suitable for use as the third argument to the setvbuf function. Expands to an integral constant expression, which is the size of the buffer used by the setbuf function. Expands to a negative integral constant expression that is returned by several functions to indicate end-of-file. Expands to an integral constant expression that is the minimum number of files that the Compaq C compiler for your system guarantees can be open simultaneously. Expands to an integral constant expression that is the size needed for an array of char large enough to hold the longest file name string that the Compaq C compiler for your system guarantees can be opened. Expands to an integral constant expression that is the size needed for an array of char large enough to hold a temporary file name string generated by the tmpnam function. Expand to integral constant expressions with distinct values; suitable for use as the third argument to the fseek function. Expands to an integral constant expression that is the minimum number of unique file names that can be generated by the tmpnam function. Expressions of type pointer to FILE that point to the FILE objects associated, respectively, with the standard error, input, and output streams. int remove(const char *filename); Makes the file whose name is pointed to by filename no longer accessible by that name. Any subsequent attempt to open that file using that name will fail. The remove function returns 0 if the operation succeeds, nonzero if it fails. If the file is open, the behavior of this function is implementation-defined. int rename(const char *old, const char *new); Renames the file from the name pointed to by old to the name pointed to by new. The file is no longer accessible by the old name. The rename function returns 0 if the operation succeeds, nonzero if it fails (in which case the file, if it existed, is still known by its original name). If the new file exists before rename is called, the behavior of this function is implementation-defined. Creates a temporary binary file that is automatically removed when it is closed or when program execution ends. If execution ends abnormally, whether an open temporary file is removed is implementation-dependent. The file is opened for update with wb+ mode (see Table 9-1). The tmpfile function returns a pointer to the stream of the file that it created. If the file cannot be created, tmpfile returns a null pointer. Generates a valid file name that is different than the name of an existing file. Each call to tmpnam , up to TMP_MAX times, generates a different name. If tmpnam is called more than TMP_MAX times, the behavior is implementation-defined. Flushes the stream pointed to by stream and closes the associated file. Any unwritten buffered data for the stream is delivered to the host environment to be written to the file. Any unread buffered data is discarded. The stream is disassociated from the file. If the associated buffer was automatically allocated, it is deallocated. The fclose function returns 0 if the stream was successfully closed, or it returns EOF if any errors are detected. If stream points to an output stream or an update stream in which the most recent operation was not input, the fflush function delivers any unwritten data to the host environment to be written to the file. Otherwise, the behavior is undefined. If stream is a null pointer, fflush flushes all output or update streams in which the most recent operation was not input. The fflush function returns 0 if the operation is successful, or it returns EOF if a write error occurs. FILE *fopen(const char *filename, const char *mode); Opens the file pointed to by filename and associates a stream with it. The argument mode points to a string beginning with one of the character sequences listed in Table 9-1. Additional characters can follow these sequences. FILE *freopen(const char *filename, const char *mode, FILE *stream); Opens the file pointed to by filename and associates the stream pointed to by stream with it. The mode argument is used in the same way as with the fopen function. The freopen function first tries to close any file associated with the specified stream. Failure to close the file successfully is ignored. The error and end-of-file indicators for the stream are cleared. void setbuf(FILE *stream, char *buf); Except that it returns no value, the setbuf function is equivalent to the setvbuf function invoked with the values _IOFBF for mode and BUFSIZ for size, or (if buf is a null pointer) with the value _IONBF for mode. int setvbuf(FILE *stream, char *buf, int mode size_t size); Associates a buffer with an input or an output file. The setvbuf function can be used only after the stream pointed to by stream has been associated with an open file and before any other operation is performed on the stream. The argument mode determines how stream is to be buffered:
Formatted Input/Output Functions
int fprintf(FILE *stream, const char *format, ...); Writes output to the stream pointed to by stream, under control of the string pointed to by format, which specifies how subsequent arguments are converted for output. If there are an insufficient number of arguments for the format, the behavior is undefined. If the format is exhausted while arguments remain, the excess arguments are evaluated but are otherwise ignored. The fprintf function returns when the end of the format string is encountered. The fprintf function returns the number of characters transmitted, or it returns a negative value if an output error occurred. int fscanf(FILE *stream, const char *format, ...); Reads input from the stream pointed to by stream, under control of the string pointed to by format, which specifies the allowable input sequences and how they are to be converted for assignment, using subsequent arguments as pointers to the objects to receive the converted input. If there are an insufficient number of arguments for the format, the behavior is undefined. If the format is exhausted while arguments remain, the excess arguments are evaluated but are otherwise ignored. int printf(const char *format, ...); Equivalent to the fprintf function except that printf writes formatted output to the standard output stream ( stdout ). int scanf(const char *format, ...); Equivalent to the fscanf function except that scanf reads formatted input from the standard input stream ( stdin ). int sprintf(char *s, const char *format, ...); Equivalent to the fprintf function except that the argument s specifies an array, rather than a stream, into which the generated output will be written. A null character is written at the end of the characters written. If copying takes place between objects that overlap, the behavior is undefined. The sprintf function returns the number of characters written into the array, not counting the terminating null character.
| |
privacy statement and legal notices |