[an error occurred while processing this directive]
![]() |
![]() HP OpenVMS Systems Documentation |
![]() |
HP C
|
Previous | Contents | Index |
Reads bytes from a given position within a file without changing the file pointer.
#include <unistd.h>ssize_t pread (int file_desc, void *buffer, size_t nbytes, off_t offset);
file_desc
A file descriptor that refers to a file currently opened for reading.buffer
The address of contiguous storage in which the input data is placed.nbytes
The maximum number of bytes involved in the read operation.offset
The offset for the desired position inside the file.
The pread function performs the same action as read , except that it reads from a given position in the file without changing the file pointer. The first three arguments to pread are the same as for read , with the addition of a fourth argument offset for the desired position inside the file. An attempt to perform a pread on a file that is incapable of seeking results in an error.
n The number of bytes read. - 1 Upon failure, the file pointer remains unchanged and pread sets errno to one of the following values:
- EINVAL -- The offset argument is invalid. The value is negative.
- EOVERFLOW -- The file is a regular file, and an attempt was made to read or write at or beyond the offset maximum associated with the file.
- ENXIO -- A request was outside the capabilities of the device.
- ESPIPE -- fildes is associated with a pipe or FIFO.
Performs formatted output from the standard output ( stdout ). See Chapter 2 for information on format specifiers.
#include <stdio.h>int printf (const char *format_spec, ...);
format_spec
Characters to be written literally to the output or converted as specified in the ... arguments....
Optional expressions whose resultant types correspond to conversion specifications given in the format specification.If no conversion specifications are given, you may omit the output sources. Otherwise, the function call must have exactly as many output sources as there are conversion specifications, and the conversion specifications must match the types of the output sources.
Conversion specifications are matched to output sources in left-to-right order. Excess output pointers, if any, are ignored.
x The number of bytes written. Negative value Indicates that an output error occurred. The function sets errno . For a list of errno values set by this function, see fprintf .
Perform a printf in the specified window, starting at the current position of the cursor. The printw function acts on the stdscr window.
#include <curses.h>printw (char *format_spec, ...);
int wprintw (WINDOW *win, char *format_spec, ...);
win
A pointer to the window.format_spec
A pointer to the format specification string....
Optional expressions whose resultant types correspond to conversion specifications given in the format specification.If no conversion specifications are given, you may omit the output sources. Otherwise, the function call must have exactly as many output sources as there are conversion specifications, and the conversion specifications must match the types of the output sources.
Conversion specifications are matched to output sources in left-to-right order. Excess output pointers, if any, are ignored.
The formatting specification (format_spec) and the other arguments are identical to those used with the printf function.The printw and wprintw functions format and then print the resultant string to the window using the addstr function. For more information, see the printf and scrollok functions in this section. See Chapter 2 for information on format specifiers.
OK Indicates success. ERR Indicates that the function makes the window scroll illegally.
The putc macro writes a single character to a specified file.
#include <stdio.h>int putc (int character, FILE *file_ptr);
character
The character to be written.file_ptr
A file pointer to the output stream.
The putc macro writes the byte character (converted to an unsigned char) to the output specified by the file_ptr parameter. The byte is written at the position at which the file pointer is currently pointing (if defined) and advances the indicator appropriately. If the file cannot support positioning requests, or if the output stream was opened with append mode, the byte is appended to the output stream.Since putc is a macro, a file pointer argument with side effects (for example, putc (ch, *f++) ) might be evaluated incorrectly. In such a case, use the fputc function instead.
Compiling with the __UNIX_PUTC macro defined enables an optimization that uses a faster, inlined version of this function.
See also putc_unlocked .
x The character written to the file. Indicates success. EOF Indicates output errors.
Same as putc , except used only within a scope protected by flockfile and funlockfile .
#include <stdio.h>int putc_unlocked (int character, FILE *file_ptr);
character
The character to be written.file_ptr
A file pointer to the output stream.
The reentrant version of the putc macro is locked against multiple threads calling it simultaneously. This incurs overhead to ensure integrity of the stream. The unlocked version of this call, putc_unlocked can be used to avoid the overhead. The putc_unlocked macro is functionally identical to the putc macro, except that it is not required to be implemented in a thread-safe manner. The putc_unlocked macro can be safely used only within a scope that is protected by the flockfile and funlockfile functions used as a pair. The caller must ensure that the stream is locked before putc_unlocked is used.Since putc_unlocked is a macro, a file pointer argument with side effects might be evaluated incorrectly. In such a case, use the fputc_unlocked function instead.
Compiling with the __UNIX_PUTC macro defined enables an optimization that uses a faster, inlined version of this function.
See also flockfile , ftrylockfile , and funlockfile .
x The character written to the file. Indicates success. EOF Indicates the end-of-file or an error.
Writes a single character to the standard output ( stdout ) and returns the character.
#include <stdio.h>int putchar (int character);
character
An object of type int .
The putchar function is identical to fputc (character, stdout ).Compiling with the __UNIX_PUTC macro defined enables an optimization that uses a faster, inlined version of this function.
character Indicates success. EOF Indicates output errors.
Same as putchar , except used only within a scope protected by flockfile and funlockfile .
#include <stdio.h>int putchar_unlocked (int character);
character
An object of type int .
The reentrant version of the putchar function is locked against multiple threads calling it simultaneously. This incurs overhead to ensure integrity of the output stream. The unlocked version of this call, putchar_unlocked can be used to avoid the overhead. The putchar_unlocked function is functionally identical to the putchar function, except that it is not required to be implemented in a thread-safe manner. The putchar_unlocked function can be safely used only within a scope that is protected by the flockfile and funlockfile functions used as a pair. The caller must ensure that the stream is locked before putchar_unlocked is used.Compiling with the __UNIX_PUTC macro defined enables an optimization that uses a faster, inlined version of this function.
See also flockfile , ftrylockfile , and funlockfile .
x The next character from stdin , converted to int . EOF Indicates the end-of-file or an error.
Sets an environmental variable.
#include <stdlib.h>int putenv (const char *string);
string
A pointer to a name=value string.
The putenv function sets the value of an environment variable by altering an existing variable or by creating a new one. The string argument points to a string of the form name=value, where name is the environment variable and value is the new value for it.The string pointed to by string becomes part of the environment, so altering the string changes the environment. When a new string-defining name is passed to putenv , the space used by string is no longer used.
0 Indicates success. - 1 Indicates an error. errno is set to ENOMEM---Not enough memory available to expand the environment list.
The putenv function cannot take a 64-bit address. See Section 1.9.
Writes a character string to the standard output ( stdout ) followed by a new-line character.
#include <stdio.h>int puts (const char *str);
str
A pointer to a character string.
The puts function does not copy the terminating null character to the output stream.
Nonnegative value Indicates success. EOF Indicates output errors.
Writes characters to a specified file.
#include <stdio.h>int putw (int integer, FILE *file_ptr);
integer
An object of type int or long .file_ptr
A file pointer.
The putw function writes four characters to the output file as an int . No conversion is performed.
integer Indicates success. EOF Indicates output errors.
Converts a wide character to its corresponding multibyte value, and writes the result to a specified file.
#include <wchar.h>wint_t putwc (wint_t wc, FILE *file_ptr);
wc
An object of type wint_t .file_ptr
A file pointer.
Since putwc might be implemented as a macro, a file pointer argument with side effects (for example putwc (wc, *f++) ) might be evaluated incorrectly. In such a case, use the fputwc function instead.See also fputwc .
x The character written to the file. Indicates success. WEOF Indicates an output error. The function sets errno . For a list of the errno values set by this function, see fputwc .
Writes a wide character to the standard output ( stdout ) and returns the character.
#include <wchar.h>wint_t putwchar (wint_t wc);
wc
An object of type wint_t .
The putwchar function is identical to fputwc (wc, stdout ).
x The character written to the file. Indicates success. WEOF Indicates an output error. The function sets errno . For a list of the errno values set by this function, see fputwc .
Writes into a given position within a file without changing the file pointer.
#include <unistd.h>ssize_t pwrite (int file_desc, const void *buffer, size_t nbytes, off_t offset);
file_desc
A file descriptor that refers to a file currently opened for writing or updating.buffer
The address of contiguous storage from which the output data is taken.nbytes
The maximum number of bytes involved in the write operation.offset
The offset for the desired position inside the file.
The pwrite function performs the same action as write , except that it writes into a given position in the file without changing the file pointer. The first three arguments to pwrite are the same as for write , with the addition of a fourth argument offset for the desired position inside the file.
n The number of bytes written. - 1 Upon failure, the file pointer remains unchanged and pwrite sets errno to one of the following values:
- EINVAL -- The offset argument is invalid. The value is negative.
- ESPIPE -- fildes is associated with a pipe or FIFO.
Returns the absolute value of an integer as an __int64 . llabs is a synonym for qabs .
#include <stdlib.h>__int64 qabs (__int64 j);
__int64 llabs (__int64 j);
j
A value of type __int64 .
Returns the quotient and the remainder after the division of its arguments. lldiv is a synonym for qdiv .
#include <stdlib.h>qdiv_t qdiv (__int64 numer, __int64 denom);
lldiv_t lldiv (__int64 numer, __int64 denom);
numer
A numerator of type __int64 .denom
A denominator of type __int64 .
The types qdiv_t and lldiv_t are defined in the <stdlib.h> header file as follows:
typedef struct { __int64 quot, rem; } qdiv_t, lldiv_t;
Previous | Next | Contents | Index |