![]() |
![]() HP OpenVMS Systems Documentation |
![]() |
2.6 Program ExamplesThis section gives some program examples that show how the I/O functions can be used in applications. Example 2-1 shows the printf function.
Running Example 2-1 produces the following output:
Example 2-2 shows the use of the fopen , ftell , sprintf , fputs , fseek , fgets , and fclose functions.
Running Example 2-2 produces the following result:
The output to DATA.DAT from Example 2-2 is:
Running Example 2-3 produces the following result:
The output to DATA.DAT from Example 2-3 is:
Example 2-4 shows the use of both a file pointer and a file descriptor to access a single file.
Chapter 3
|
Function | Description |
---|---|
Character Classification | |
isalnum , iswalnum | Returns a nonzero integer if its argument is one of the alphanumeric characters in the current locale. |
isalpha , iswalpha | Returns a nonzero integer if its argument is one of the alphabetic characters in the current locale. |
isascii | Returns a nonzero integer if its argument is any ASCII character. |
iscntrl , iswcntrl | Returns a nonzero integer if its argument is a control character in the current locale. |
isdigit , iswdigit | Returns a nonzero integer if its argument is a digit character in the current locale. |
isgraph , iswgraph | Returns a nonzero integer if its argument is a graphic character in the current locale. |
islower , iswlower | Returns a nonzero integer if its argument is a lowercase character in the current locale. |
isprint , iswprint | Returns a nonzero integer if its argument is a printing character in the current locale. |
ispunct , iswpunct | Returns a nonzero integer if its argument is a punctuation character in the current locale. |
isspace , iswspace | Returns a nonzero integer if its argument is a white-space character in the current locale. |
isupper , iswupper | Returns a nonzero integer if its argument is an uppercase character in the current locale. |
iswctype | Returns a nonzero integer if its argument has the specified property. |
isxdigit , iswxdigit | Returns a nonzero integer if its argument is a hexadecimal digit (0 to 9, A to F, or a to f). |
Character Conversion | |
btowc | Converts a one-byte multibyte character to a wide character in the initial shift state. |
ecvt, fcvt, gcvt | Converts an argument to a null-terminated string of ASCII digits and return the address of the string. |
index, rindex | Searches for a character in a string. |
mblen , mbrlen | Determines the number of bytes in a multibyte character. |
mbsinit | Determines whether an mbstate_t object decribes an initial conversion state. |
mbstowcs | Converts a sequence of multibyte characters into a sequence of corresponding codes. |
toascii | Converts its argument, an 8-bit ASCII character, to a 7-bit ASCII character. |
tolower, _tolower, towlower | Converts its argument, an uppercase character, to lowercase. |
toupper, _toupper, towupper | Converts its argument, a lowercase character, to uppercase. |
towctrans | Maps one wide character to another according to a specified mapping descriptor. |
wcstombs | Converts a sequence of wide-character codes corresponding to multibyte characters to a sequence of multibyte characters. |
wctob | Determines if a wide character corresponds to a single-byte multibyte character and returns its multibyte character representation. |
wctomb | Converts a wide character to its multibyte character representation. |
wctrans | Returns the description of a mapping, corresponding to specified property, that can be later used in a call to towctrans . |
wctype | Converts a valid character class defined for the current locale to an object of type wctype_t . |
String Manipulation | |
atof | Converts a given string to a double-precision number. |
atoi, atol | Converts a given string of ASCII characters to the appropriate numeric values. |
atoll, atoq (INTEGRITY SERVERS, ALPHA) | Converts a given string of ASCII characters to an __int64 . |
basename | Returns the last component of a path name. |
dirname | Reports the parent directory name of a file path name. |
strcat, strncat, wcscat, wcsncat | Appends one string to the end of another string. |
strchr, strrchr, wcschr, wcsrchr | Returns the address of the first or last occurrence of a given character in a null-terminated string. |
strcmp, strncmp, strcoll, wcscmp, wcsncmp, wcscoll | Compares two character strings and returns a negative, zero, or positive integer indicating that the values of the individual characters in the first string are less than, equal to, or greater than the values in the second string. |
strcpy, strncpy, wcscpy, wcsncpy | Copies all or part of one string into another. |
strxfrm, wcsxfrm | Transforms a multibyte string to another string ready for comparisons using the strcmp or wcscmp function. |
strcspn, wcscspn | Searches a string for a character that is in a specified set of characters. |
strlen, wcslen | Returns the length of a string of characters. The returned length does not include the terminating null character (\0). |
strpbrk, wcspbrk | Searches a string for the occurrence of one of a specified set of characters. |
strspn, wcsspn | Searches a string for the occurrence of a character that is not in a specified set of characters. |
strstr, wcswcs | Searches a string for the first occurrence of a specified set of characters. |
strtod, wcstod | Converts a given string to a double-precision number. |
strtok, wcstok | Locates text tokens in a given string. |
strtol, wcstol | Converts the initial portion of a string to a signed long integer. |
strtoll, strtoq (INTEGRITY SERVERS, ALPHA) | Converts the initial portion of a string to signed __int64 . |
strtoul, wcstoul | Converts the initial portion of a string to an unsigned long integer. |
strtoull, strtouq (INTEGRITY SERVERS, ALPHA) | Converts the initial portion of the string pointed to by the pointer to the character string to an unsigned __int64 . |
String Handling---Accessing Binary Data | |
bcmp | Compares byte strings. |
bcopy | Copies byte strings. |
bzero | Copies nulls into byte strings. |
memchr, wmemchr | Locates the first occurrence of the specified byte within the initial length of the object to be searched. |
memcmp, wmemcmp | Compares two objects byte by byte. |
memcpy, memmove, wmemcpy, wmemmove | Copies a specified number of bytes from one object to another. |
memset, wmemset | Sets a specified number of bytes in a given object to a given value. |
Argument-List Handling---Accessing a Variable-Length Argument List | |
va_arg | Returns the next item in the argument list. |
va_count | Returns the number of quadwords (ALPHA ONLY) in the argument list. |
va_end | Finishes the va_start session. |
va_start, va_start_1 | Initializes a variable to the beginning of the argument list. |
vfprintf, vprintf, vsprintf | Prints formatted output based on an argument list. |
Previous | Next | Contents | Index |