Header File Contents (cont.)
Searching Utilities <search.h>
The header <search.h> contains identifiers used for creating and
searching binary trees and hash tables. The following identifiers are
declared:
Table 4-8. Search Utilities <search.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ACTION | type definition | An enumerated type with the enumerated constants |
| | | FIND and ENTER. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ENTRY | type definition | A structured type defining a record with a search |
| | | key and data. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| hcreate() | function | Allocates sufficient space for a hash table used by |
| | | hsearch(). |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| hdestroy() | function | Destroys a search table created by hcreate(). |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| lsearch() | function | Performs a linear search and update. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| tdelete() | function | Deletes a specified node from a binary search tree. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| tfind() | function | Searches for a specified entry in a binary search |
| | | tree. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| tsearch() | function | Returns a pointer into a hash table indicating the |
| | | location of a specified entry. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| twalk() | function | Traverses a binary search tree and returns the |
| | | value at the specified node. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| VISIT | type definition | An enumerated type with the enumerated constants |
| | | preorder, postorder, endorder, and leaf. |
| | | |
-----------------------------------------------------------------------------------------------
NOTE This header file is not defined by the ANSI C standard. Programs
using this header are likely to be less portable.
Non-local Jumps <setjmp.h>
The header <setjmp.h> declares a type and several functions for bypassing
the normal function call and return discipline. The following
identifiers are declared in this header file:
Table 4-9. Nonlocal Jumps <setjmp.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| jmp_buf | type definition | An array type used by setjmp to save and by longjmp |
| | | to restore a program's environment. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| longjmp() | function | Restores an environment previously saved by |
| | | setjmp(). |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| setjmp() | function | Saves the current environment. |
| | | |
-----------------------------------------------------------------------------------------------
Signal Handling <signal.h>
The header <signal.h> declares a type, functions, and macros for handling
various signals that can be raised during program execution.
The following identifiers are defined in <signal.h>:
Table 4-10. Signal Handling <signal.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| raise | function | Causes a signal to be raised. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| sig_atomic_t | type definition | An integral type, such that an object of this type |
| | | can be accessed in an atomic fashion (in one |
| | | operation), even in the presence of external |
| | | interrupts. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SIG_DFL | macro | Passed as the second parameter to signal(). |
| | | Specifies default signal handling. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SIG_ERR | macro | Returned by signal() to indicate an error when |
| | | calling the signal function. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SIG_IGN | macro | Passed as the second parameter to signal(). |
| | | Specifies that exceptions should be ignored. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SIGABRT | macro | The signal raised by the abort function indicating |
| | | abnormal termination. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SIGFPE | macro | A signal indicating that a floating-point exception |
| | | or erroneous arithmetic operation has occurred (for |
| | | example, divide by 0). |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SIGILL | macro | A signal indicating that an illegal instruction was |
| | | executed (possibly after a jump). |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SIGINT | macro | A signal indicating that an interactive interrupt |
| | | has been received. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| signal | function | Specifies how a signal is to be handled. |
| | | |
-----------------------------------------------------------------------------------------------
Table 4-10. Signal Handling <signal.h> (cont.)
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SIGSEGV | macro | A signal indicating that an invalid address to |
| | | storage has been requested. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SIGTERM | macro | A signal indicating that a termination request was |
| | | sent to the program. |
| | | |
-----------------------------------------------------------------------------------------------
Variable Number of Arguments <stdarg.h>
The header <stdarg.h> contains a type definition and three macros. These
can be used to determine the arguments of a function that can be called
with a variable number of arguments. The variable number of arguments is
indicated by an ellipsis in the function declaration.
NOTE The header <varargs.h> also contains the same type definitions and
macros described in this section. However, <varargs.h> is not
defined by the ANSI C standard.
The following identifiers are defined in <stdarg.h>:
Table 4-11. Variable Number of Arguments <stdarg.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| va_arg | macro | Returns the type and value of the next argument in |
| | | the argument list ap. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| va_end | macro | Terminates access to the variable argument list by |
| | | making ap unusable. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| va_list | type definition | A pointer to a double used to store information |
| | | needed by the <stdarg.h> macros. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| va_start | macro | Initializes the ap pointer (of type va_list) to the |
| | | argument list for subsequent use by va_arg and |
| | | va_end. |
| | | |
-----------------------------------------------------------------------------------------------
Common Definitions <stddef.h>
The following identifiers are defined in <stddef.h>:
Table 4-12. Common Definitions <stddef.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| NULL | macro | The constant 0. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| offsetof(type, | macro | Expands to an integral constant that has type |
| identifier) | | size_t, the value of which is the offset in bytes, |
| | | from the beginning of a structure designated by |
| | | type, of the member designated by identifier. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ptrdiff_t | type definition | The signed integral type of subtracting two |
| | | pointers. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| size_t | type definition | The unsigned integral type of the sizeof operator. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| wchar_t | type definition | The integral data type large enough to represent |
| | | all members of the largest extended character set |
| | | among the supported locales. |
| | | |
-----------------------------------------------------------------------------------------------
Input/Output <stdio.h>
The header <stdio.h> defines a structure, functions, and macros that are
used for input and output.
The following identifiers are defined in <stdio.h>:
Table 4-13. Input/Output <stdio.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| BUFSIZ | macro | Specifies the size of the buffers used by setbuf. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| clearerr() | macro, function | Clears the end-of-file and error indicator of a |
| | | stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ctermid()(1) | function | Returns $stdlist as the file name for the terminal. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| EOF | macro | Returned upon end-of-file or upon error by most |
| | | integer functions that deal with streams. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fclose() | function | Closes an open file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fdopen()(1) | function | Opens a stream on a file descriptor. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| feof() | macro, function | Tests whether the end-of-file indicator for a |
| | | stream has been set. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ferror() | macro, function | Tests whether the error indicator for a stream has |
| | | been set. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fflush() | function | Flushes an I/O buffer to a file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fgetc() | function | Returns the next character from an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fgetpos() | function | Returns the current file position of an open |
| | | stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fgets() | function | Reads a string from an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
Table 4-13. Input/Output <stdio.h> (cont.)
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| FILE | type definition | A type definition for a file descriptor. This type |
| | | defines a data structure used internally by the I/O |
| | | routines to identify open files and maintain |
| | | context when accessing files. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| FILENAME_MAX | macro | Specifies the maximum number of characters allowed |
| | | in a file name. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fileno()(2) | macro, function | Maps a stream pointer to a file descriptor. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fopen() | function | Opens a file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| FOPEN_MAX | macro | Specifies the minimum number of files that the |
| | | operating system guarantees may be opened |
| | | simultaneously. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fpos_t | type definition | A type definition for an object capable of defining |
| | | all unique locations within a file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fprintf() | function | Writes data in formatted form to an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fputc() | function | Writes a character to an output stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fputs() | function | Writes a string to an output stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fread() | function | Reads data items from an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| freopen() | function | Closes and reopens a stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fscanf() | function | Reads externally formatted data from an open |
| | | stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fseek() | function | Positions the next I/O operation on an open stream |
| | | to an new position. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fsetpos() | function | Sets the file position for the stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ftell() | function | Returns the current file position indicator for the |
| | | next I/O operation on an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| fwrite() | function | Writes data items to an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
Table 4-13. Input/Output <stdio.h> (cont.)
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| getc() | macro, function | Reads a character from an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| getchar() | macro, function | Reads a character from the standard input stream |
| | | stdin. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| gets() | function | Reads a string from the standard input stream |
| | | stdin. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| getw()(3) | function | Reads a word (4 bytes) from an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| L_tmpnam | macro | Specifies the number of bytes needed to hold a |
| | | temporary file name generated by the tmpnam |
| | | function. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| NULL | macro | The constant 0. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| perror() | function | Prints an error message corresponding to the errno |
| | | global variable. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| printf() | function | Writes data in formatted form to the standard |
| | | output stream stdout. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| putc() | macro, function | Writes a character to an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| putchar() | macro, function | Writes a character to the standard output stream |
| | | stdout. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| puts() | function | Writes a string to the standard output stream |
| | | stdout. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| putw()(3) | function | Writes a word (4 bytes) to an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| remove() | function | Purges an existing file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| rename() | function | Renames an existing file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| rewind() | function | Sets the file position indicator for a stream to |
| | | the beginning of the file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| scanf() | function | Reads externally formatted data from the standard |
| | | input stream stdin. |
| | | |
-----------------------------------------------------------------------------------------------
Table 4-13. Input/Output <stdio.h> (cont.)
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SEEK_CUR | macro | A constant value that may be used as the ptrname |
| | | parameter to fseek. Seek relative to the current |
| | | location in the file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SEEK_END | macro | A constant value that may be used as the ptrname |
| | | parameter to fseek. Seek relative to the end of |
| | | file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SEEK_SET | macro | A constant value that may be used as the ptrname |
| | | parameter to fseek. Seek relative to the beginning |
| | | of file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| setbuf() | function | Assigns a buffer to an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| setvbuf() | function | Assigns a buffer and buffering method to an open |
| | | stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| size_t | type definition | The unsigned integral type of the sizeof operator. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| sprintf() | function | Writes formatted data to a character string in |
| | | memory. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| sscanf() | function | Reads formatted data from a character string in |
| | | memory. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| stderr | macro | The standard error file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| stdin | macro | The standard input file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| stdout | macro | The standard output file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| TMP_MAX | macro | The maximum number of unique file names that can be |
| | | generated by the tmp_name function. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| tmpfile() | function | Creates a temporary file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| tmpnam() | function | Creates a name for a temporary file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ungetc() | function | Pushes back a single character onto an open stream. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| vfprintf() | function | Writes data in formatted form to an open stream |
| | | using a variable argument list. |
| | | |
-----------------------------------------------------------------------------------------------
Table 4-13. Input/Output <stdio.h> (cont.)
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| vprintf() | function | Writes data in formatted form to an open stream |
| | | using a variable argument list. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| vsprintf() | function | Writes formatted data to a character string in |
| | | memory using a variable argument list. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| _IOFBF, _IOLBF, | macro | Constant expressions with values suitable for use |
| _IONBF | | as the third argument to the setvbuf function. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| _NFILE (4) | macro | Defines the maximum number of open files allowed |
| | | per process. |
| | | |
-----------------------------------------------------------------------------------------------
(1) These identifiers are not defined by the ANSI C standard. Programs
using these identifiers are likely to be less portable.
(2) These identifiers are not defined by the ANSI C standard. Programs
using these identifiers are likely to be less portable.
(3) These identifiers are not defined by the ANSI C standard. Programs
using these identifiers are likely to be less portable.
(4) These identifiers are not defined by the ANSI C standard. Programs
using these identifiers are likely to be less portable.
General Utilities <stdlib.h>
The header <stdlib.h> contains a number of general-purpose declarations
and definitions. It defines functions used for:
* string data type conversion
* multibyte character and string manipulation
* memory management
* array searching and sorting
* integer arithmetic
* communicating with the environment
The following identifiers are defined in <stdlib.h>:
Table 4-14. General Utilities <stdlib.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| abort() | function | Terminates a program abnormally. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| abs() | function | Computes the absolute value of an integer. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| atexit() | function | Specifies a function to call when a program |
| | | terminates. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| atof() | function | Converts a string to a double floating-point value. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| atoi() | function | Converts a string to an integer. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| atol() | function | Converts a string to a long integer. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| bsearch() | function | Performs a binary search of a sorted array. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| calloc() | function | Allocates a block of memory. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| div() | function | Computes the quotient and remainder of two |
| | | integers. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| div_t | type definition | A data type definition used when declaring the |
| | | return value for div(). |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| exit() | function | Terminates the calling process normally. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| EXIT_FAILURE | macro | A value that can be passed to the exit function to |
| | | indicate unsuccessful program termination. |
| | | |
-----------------------------------------------------------------------------------------------
Table 4-14. General Utilities <stdlib.h> (cont.)
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| EXIT_SUCCESS | macro | A value that can be passed to the exit function to |
| | | indicate successful program termination. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| free() | function | Frees a block of allocated memory. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| getenv() | function | Returns the value of an environment variable. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| labs() | function | Computes the absolute value of a long integer. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ldiv() | function | Computes the quotient and remainder of two long |
| | | integers. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ldiv_t | type definition | A data type definition used when declaring the |
| | | return value for ldiv(). |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| malloc() | function | Allocates a block of memory. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| mblen() | function | Determines the number of characters in a multibyte |
| | | character. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| mbstowcs() | function | Converts a sequence of multibyte characters in a |
| | | null-terminated string to a sequence of wide |
| | | character codes. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| mbtowc() | function | Converts a single multibyte character to its wide |
| | | character representation. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| MB_CUR_MAX | macro | Maximum size in bytes of a multibyte character. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| NULL | macro | The constant 0. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| qsort() | function | Sorts an array of objects. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| rand() | function | Returns a random number. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| RAND_MAX | macro | The maximum value returned by the rand function. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| realloc() | function | Changes the size of a block of allocated memory. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| size_t | type definition | The unsigned integral type of the sizeof operator. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| srand() | function | Sets a starting point for calls to the rand |
| | | function. |
| | | |
-----------------------------------------------------------------------------------------------
Table 4-14. General Utilities <stdlib.h> (cont.)
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strtod() | function | Converts a string to a double-precision, |
| | | floating-point number. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strtol() | function | Converts a string to a long integer value. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strtoul() | function | Converts a string to an unsigned integer |
| | | representation. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| system() | function | Executes an MPE/iX command. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| wchar_t | type definition | A data type definition used for wide characters. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| wcstombs() | function | Converts a sequence of wide character codes to a |
| | | sequence of multibyte characters. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| wctomb() | function | Converts a single wide character value to its |
| | | multibyte character representation. |
| | | |
-----------------------------------------------------------------------------------------------
String Handling <string.h>
The header <string.h> declares several functions for manipulating
character arrays and other objects treated as character arrays. A string
is a sequence of characters terminated by and including the first null
character. A pointer to a string is a pointer to its first character.
The length of the string is the number of characters preceding the first
null character.
The following identifiers are declared by <string.h>:
Table 4-15. String Handling <string.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| memchr() | function | Searches memory for a specified character. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| memcmp() | function | Compares the first n characters of two objects. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| memcpy() | function | Copies a specified number of characters from one |
| | | object to another. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| memmove() | function | Copies a specified number of characters from one |
| | | object to another. Allows source and destination |
| | | objects to overlap. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| memset() | function | Initializes an object with a supplied character |
| | | value. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| NULL | macro | The constant 0. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| size_t | type definition | The unsigned integral type of the sizeof operator. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strcat() | function | Appends one string to another. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strchr() | function | Locates the first occurrence of a specified |
| | | character within a string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strcmp() | function | Compares two strings and returns an integer |
| | | indicating the result of the comparison. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strcpy() | function | Copies the contents of one string to another |
| | | string. |
| | | |
-----------------------------------------------------------------------------------------------
Table 4-15. String Handling <string.h> (cont.)
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strcspn() | function | Returns the length of the first substring in one |
| | | string composed entirely of non-members of the |
| | | character set of another string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strerror() | function | Maps an error number to a message string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strlen() | function | Computes the length of the string pointed to by s. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strncat() | function | Appends a copy of one string to another string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strncmp() | function | Compares two strings up to a maximum of n |
| | | characters and returns the result of the |
| | | comparison. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strncpy() | function | Copies all or part of one string into another |
| | | string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strpbrk() | function | Returns a pointer to the location in one string of |
| | | the first occurrence of any member of the character |
| | | set in another string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strrchr() | function | Locates the last occurrence of a supplied character |
| | | within a string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strspn() | function | Returns the length of the first substring in one |
| | | string composed entirely of members of the |
| | | character set in another string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strstr() | function | Locates the first occurrence in one string of the |
| | | sequence of characters specified by another string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strtok() | function | Divides one string into zero or more tokens. The |
| | | token separators consist of any characters |
| | | contained in another string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strxfrm() | function | Transforms a string in a manner appropriate for the |
| | | current locale. |
| | | |
-----------------------------------------------------------------------------------------------
Date and Time <time.h>
The header <time.h> declares data types, global variables, and functions
for storing and manipulating time values.
The date and time functions enable you to access the date and time
maintained by the system clock. The functions handle daylight savings
time, and automatically convert between standard time and daylight
savings time when appropriate.
Most of the functions require the calendar time returned by time(), that
is the number of seconds that have elapsed since 00:00:00 Coordinated
Universal Time (UTC), January 1, 1970.
The following identifiers are declared in this header file:
Table 4-16. Date and Time <time.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| asctime() | function | Converts a tm structured time variable into |
| | | a null terminated 26-character string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| clock() | function | Reports CPU time used. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| clock_t | type definition | Return values from the clock function. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| CLOCKS_PER_SEC | macro | The number of clock ticks per second, as |
| | | counted by the clock function. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ctime() | function | Converts a calendar time into a |
| | | 26-character ASCII string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| daylight (1) | global variable | Communicates with functions in this |
| | | library. See the function descriptions in |
| | | chapter 5 for more information. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| difftime() | function | Computes the difference between two times. |
| | | |
-----------------------------------------------------------------------------------------------
Table 4-16. Date and Time <time.h> (cont.)
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| gmtime() | function | Converts time to Coordinated Universal Time |
| | | (UTC) in the structured tm type format. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| localtime() | function | Converts time to the local time zone. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| mktime() | function | Converts a broken-down time of type struct |
| | | tm to a calendar time of of type time_t. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| NULL | macro | The constant 0. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| size_t | type definition | The data type used to return values from |
| | | the sizeof operator. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| strftime() | function | Creates a formatted time string. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| time() | function | Returns the current calendar time. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| time_t | type definition | A data type definition used to return |
| | | values from the time function. It is also |
| | | used to declare return values and |
| | | parameters of other <time.h> functions. A |
| | | time value represented using type time_t is |
| | | referred to as a calendar time. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| timezone | macro | A constant containing the offset of the |
| | | local time zone to GMT. The local time zone |
| | | defaults to EST. This value can be changed |
| | | by setting the environment variable TZ |
| | | using the SETVAR command. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| tm | type definition | A structure data type definition used to |
| | | declare parameters and return values for |
| | | <time.h> functions. Contains the |
| | | components of a calendar time value, broken |
| | | down into individual fields for year, |
| | | month, day, hour, and so on. A time value |
| | | represented using type struct tm is |
| | | referred to as a broken-down time. |
| | | |
-----------------------------------------------------------------------------------------------
Table 4-16. Date and Time <time.h> (cont.)
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| tzname (2) | global variable | An external variable used to communicate |
| | | with functions in this library. See the |
| | | time function descriptions in chapter 5 for |
| | | more information. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| tzset()(2) | function | Sets time zone conversion information. |
| | | |
-----------------------------------------------------------------------------------------------
(1) These identifiers are not defined by the ANSI C standard. Programs
using these identifiers are likely to be less portable.
(2) These identifiers are not defined by the ANSI C standard. Programs
using these identifiers are likely to be less portable.
The tm structure, used by several of the <time.h> functions, is shown
below:
struct tm {
int tm_sec; /* seconds after the minute (0 through 59) */
int tm_min; /* minutes after the hour (0 through 59) */
int tm_hour; /* hours since midnight (0 through 23) */
int tm_mday; /* day of the month (1 through 31) */
int tm_mon; /* month of the year (0 through 11) */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday (0 through 6) */
int tm_yday; /* day of the year (0 through 365) */
int tm_isdst; /* daylight savings time flag (1 = dst) */
};
Standard Macros <unistd.h>
The header <unistd.h> defines several macros that are used as arguments
to the lseek function.
Table 4-17. Standard Macros<unistd.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SEEK_CUR | macro | A constant value that may be used as the whence |
| | | parameter to lseek. Seek relative to the current |
| | | location in the file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SEEK_END | macro | A constant value that may be used as the whence |
| | | parameter to lseek. Seek relative to the end of |
| | | file. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| SEEK_SET | macro | A constant value that may be used as the whence |
| | | parameter to lseek. Seek relative to the beginning |
| | | of file. |
| | | |
-----------------------------------------------------------------------------------------------
NOTE This header file is not defined by the ANSI C standard. Programs
using this header are likely to be less portable.
Machine-Dependent Values <values.h>
The header <values.h> contains a set of manifest constants, conditionally
defined for particular processor architectures. The model assumed for
integers is binary representation (one's or two's complement), where the
sign is represented by the value of the high-order bit. The following
macros are defined in this header file:
Table 4-18. Machine-Dependent Values<values.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| BITS | macro | The number of bits in a specified type, such as |
| | | int. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| HIBITS | macro | The value of a short integer with only the |
| | | high-order bit set. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| HIBITL | macro | The value of a long integer with only the |
| | | high-order bit set. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| HIBITI | macro | The value of a regular integer with only the |
| | | high-order bit set. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| MAXSHORT | macro | The maximum value of a signed short integer. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| MAXLONG | macro | The maximum value of a signed long integer. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| MAXINT | macro | The maximum value of a signed regular integer. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| MAXFLOAT, | macros | The maximum value of a single-precision |
| LN_MAXFLOAT | | floating-point number and its natural logarithm. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| MAXDOUBLE, | macros | The maximum value of a double-precision |
| LN_MAXDOUBLE | | floating-point number and its natural logarithm. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| MINFLOAT, | macros | The minimum positive value of a single-precision |
| LN_MINFLOAT | | floating-point number and its natural logarithm. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| MINDOUBLE, | macros | The minimum positive value of a double-precision |
| LN_MINDOUBLE | | floating-point number and its natural logarithm. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| FSIGNIF | macro | The number of significant bits in the mantissa of a |
| | | single-precision floating-point number. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| DSIGNIF | macro | The number of significant bits in the mantissa of a |
| | | double-precision floating-point number. |
| | | |
-----------------------------------------------------------------------------------------------
NOTE This header file is not defined by the ANSI C standard. Programs
using this header are likely to be less portable.
Variable Arguments (old form) <varargs.h>
The header <varargs.h> declares several types and macros for calling
variable argument functions.
Table 4-19. Variable Arguments <varargs.h>
-----------------------------------------------------------------------------------------------
| | | |
| Name | Type | Description |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| va_arg | macro | Returns the next argument in an argument list. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| va_alist | type definition | A type definition used when declaring the variable |
| | | used as the ap parameter to the va_arg, va_end, and |
| | | va_start macros. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| va_start | macro | Initializes a variable to the beginning of an |
| | | argument list. |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| va_end | macro | Terminates access to a variable argument list. |
| | | |
-----------------------------------------------------------------------------------------------
NOTE This header file is for non-ANSI mode only. Use <stdarg.h> in ANSI
mode. Using this header is likely to make a program less portable.