Previous | Contents | Index |
The following example shows how to print a date and time in the form "Sunday, July 3, 10:02", followed by <pi symbol> to five decimal places:
#include <math.h> #include <stdio.h> #include <wchar.h> /*...*/ wchar_t *weekday, *month; /* pointers to wide-character strings */ int day, hours, min; fwprintf(stdout, L"%ls, %ls %d, %.2d:%.2d\n", weekday, month, day, hour, min); fwprintf(stdout, L"pi = %.5f\n", 4 * atan(1.0)); |
Reads input from the stream under control of the wide-character format string.
#include <wchar.h>int fwscanf (FILE *stream, const wchar_t *format, ...);
stream
A file pointer.format
A pointer to a wide-character string containing the format specification. For more information about format and conversion specifications and their corresponding arguments, see Chapter 2....
Optional expressions whose results correspond to conversion specifications given in the format specification. For more information about format and conversion specifications and their corresponding arguments, see Chapter 2.If no conversion specifications are given, you can omit the input pointers. Otherwise, the function calls must have exactly as many input pointers as there are conversion specifications, and the conversion specifications must match the types of the input pointers.
Conversion specifications are matched to input sources in left-to-right order. Excess input pointers, if any, are ignored.
This function reads input from the stream pointed to by stream under the control of the wide-character string pointed to by format. If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while arguments remain, the excess arguments are evaluated, but otherwise ignored.The format is composed of zero or more directives that include:
- One or more white-space wide characters.
- An ordinary wide character (neither a percent (%)) nor a white-space wide character).
- Conversion specifications.
Each conversion specification is introduced by the wide character %.
If the stream pointed to by the stream argument has no orientation, fwscanf makes the stream wide-oriented.
n The number of input items assigned, sometimes fewer than provided for, or even zero, in the event of an early matching failure. EOF Indicates an error; input failure occurs before any conversion.
Converts its argument to a null-terminated string of ASCII digits and returns the address of the string.
#include <stdlib.h>Function Variants This function also has variants named _gcvt32 and _gcvt64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.char *gcvt (double value, int ndigit, char *buffer);
value
An object of type double that is converted to a null-terminated string of ASCII digits.ndigit
The number of ASCII digits to use in the converted string. If ndigit is less than 6, the value of 6 is used.buffer
A storage location to hold the converted string.
This function places the converted string in a buffer and returns the address of the buffer. If possible, gcvt produces ndigit significant digits in F-format, or if not possible, in E-format. Trailing zeros are suppressed.The ecvt , fcvt , and gcvt functions represent the following special values specified in the IEEE Standard for floating-point arithmetic:
Value Representation Quiet NaN NaNQ Signalling NaN NaNS +Infinity Infinity --Infinity --Infinity The sign associated with each of these values is stored into the sign argument. In IEEE floating-point representation, a value of 0 (zero) can be positive or negative, as set by the sign argument.
See also fcvt and ecvt in this section.
x The address of the buffer.
The getc macro returns the next character from a specified file.
#include <stdio.h>int getc (FILE *file_ptr);
file_ptr
A pointer to the file to be accessed.
Since getc is a macro, a file pointer argument with side effects (for example, getc (*f++) ) might be evaluated incorrectly. In such a case, use the fgetc function instead. See the fgetc function in this section.
n The returned character. EOF Indicates the end-of-file or an error.
Get a character from the terminal screen and echo it on the specified window. The getch function echos the character on stdscr.
#include <curses.h>char getch();
char wgetch (WINDOW *win);
win
A pointer to the window.
The getch and wgetch functions refresh the specified window before fetching a character. For more information, see the scrollok function in this section.
x The returned character. ERR Indicates that the function makes the screen scroll illegally.
Reads a single character from the standard input (stdin).
#include <stdio.h>int getchar (void);
The getchar function is identical to fgetc (stdin).
x The next character from stdin, converted to int . EOF Indicates the end-of-file or an error.
Gets the current value of the system-wide clock.
#include <timers.h>int getclock (int clktyp, struct timespec *tp);
clktyp
The type of system-wide clock.tp
Pointer to a timespec structure space where the current value of the system-wide clock is stored.
This function sets the current value of the clock specified by clktyp into the location pointed to by tp.The clktyp argument is given as a symbolic constant name, as defined in the <timers.h> header file. Only the timeofday symbolic constant, which specifies the normal time-of-day clock to access for system-wide time, is supported.
For the clock specified by timeofday , the value returned by this function is the elapsed time since the Epoch. The Epoch is referenced to 00:00:00 UTC (Coordinated Universal Time) 1 Jan 1970.
The getclock function returns a timespec structure, which is defined in the <timers.h> header file as follows:
struct timespec { unsigned long tv_sec /* Elapsed time in seconds since the Epoch*/ long tv_nsec /* Elapsed time as a fraction of a second */ /* since the Epoch (expressed in nanoseconds */ };
0 Indicates success. --1 Indicates an error; errno is set to one of the following values:
- EINVAL -- The clktyp argument does not specify a known system-wide clock.
- EIO -- An error occurred when the system-wide clock specified by the clktyp argument was accessed.
Returns a pointer to the file specification for the current working directory.
#include <unistd.h>Function Variants This function also has variants named _getcwd32 and _getcwd64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.char *getcwd (char *buffer, size_t size);
(ISO POSIX-1) char *getcwd (char *buffer, unsigned int size, ...);
(DEC C EXTENSION)
buffer
Pointer to a character string large enough to hold the directory specification.If buffer is a NULL pointer, getcwd obtains size bytes of space using malloc . In this case, you can use the pointer returned by getcwd as the argument in a subsequent call to free .
size
The length of the directory specification to be returned....
An optional argument that can be either 1 or 0. If you specify 1, the getcwd function returns the directory specification in OpenVMS format. If you specify 0, getcwd returns the directory specification (path name) in UNIX style format. If you do not specify this argument, getcwd returns the file name according to your current command-language interpreter. For more information about UNIX style directory specifications, see Section 1.4.3.
x A pointer to the file specification. NULL Indicates an error.
Gets the total number of file descriptors that a process can have open simultaneously.
#include <unistd.h>int getdtablesize (void);
This function returns the total number of file descriptors that a process can have open simultaneously. Each process is limited to a fixed number of open file descriptors.The number of file descriptors that a process can have open is the minumum of the following:
- DEC C RTL open file limit---65535 on OpenVMS Alpha; 2048 on OpenVMS VAX.
- SYSGEN CHANNELCNT parameter---permanent I/O channel count.
- Process open file quota FILLM parameter---number of open files that can be opened by a process at one time.
x The number of file descriptors that a process can have open simultaneously. --1 Indicates an error.
Returns, in OpenVMS terms, the group number from the user identification code (UIC). For example, if the UIC is [313,031], 313 is the group number.
#include <unistd.h>gid_t getegid (void);
In DEC C for OpenVMS Systems, the getgid and getegid functions both return the group number from the current UIC. See also geteuid and getuid in this section.
x The group number from the UIC.
Searches the environment array for the current process and returns the value associated with a specified environment name.
#include <stdlib.h>char *getenv (const char *name);
name
One of the following values:
- HOME---Your login directory
- TERM---The type of terminal being used
- PATH--The default device and directory
- USER---The name of the user who initiated the process
- Logical name or CLI symbolic name
- An environment variable set with setenv or putenv .
In certain situations, this function attempts to perform a logical name translation on the user-specified argument:
- If the argument to getenv does not match any of the environment strings present in your environment array, getenv attempts to translate your argument as a logical name by searching the logical name tables indicated by the LNM$FILE_DEV logical, as is done for file processing.
getenv first does a case-sensitive lookup. If that fails, it does a case-insensitive lookup. In most instances, logical names are defined in uppercase, but getenv can also find logical names that include lowercase letters.- If no logical name exists, getenv attempts to translate the argument string as a command-language interpreter (CLI) symbol. If it succeeds, it returns the translated symbol text. If it fails, the return value is NULL.
If your CLI is the DEC/Shell, the function does not attempt a logical name translation since Shell environment symbols are implemented as DCL symbols.
x Pointer to an array containing the translated symbol. NULL Indicates that the translation failed.
Returns, in OpenVMS terms, the member number from the user identification code (UIC). For example, if the UIC is [313,031], 031 is the member number.
#include <unistd.h>uid_t geteuid (void);
In DEC C for OpenVMS Systems, getuid and geteuid perform the same function.For programs compiled with the _VMS_V6_SOURCE feature-test macro or programs that do not include the <unistd.h> header file, the getuid and geteuid functions return the member number of the OpenVMS UIC. For example, if the UIC is [313,31], then the member number, 31, is returned.
For programs compiled without the _VMS_V6_SOURCE feature-test macro that do include the <unistd.h> header file, the full UIC is returned. For example, if the UIC is [313, 31] then 20512799 (31 + 313 * 65536) is returned.
See the getegid or getgid functions in this section for the functions that return the group number.
x The member number from the current UIC.
Returns, in OpenVMS terms, the group number from the user identification code (UIC). For example, if the UIC is [313,031], 313 is the group number.
#include <unistd.h>gid_t getgid (void);
In DEC C for OpenVMS Systems, the getgid and getegid functions both return the group number from the current UIC. Similarly, getuid and geteuid both return the member number from the current UIC.
x The group number from the current UIC.
Returns the value of interval timers.
#include <time.h>int getitimer (int which, struct itimerval *value);
which
The type of interval timer. The DEC C RTL supports only ITIMER_REAL.value
Pointer to an itimerval structure whose members specify a timer interval and the time left to the end of the interval.
This function returns the current value for the timer specified by the which argument in the structure pointed to by value .A timer value is defined by the itimerval structure:
struct itimerval { struct timeval it_interval; struct timeval it_value; };The following table lists the values for the itimerval structure members:
itimerval Member Value Meaning it_interval = 0 Disables a timer after its next expiration Assumes it_value is nonzero. it_interval = nonzero Specifies a value used in reloading it_value when the timer expires. it_value = 0 Disables a timer. it_value = nonzero Indicates the time to the next timer expiration. Time values smaller than the resolution of the system clock are rounded up to this resolution.
The DEC C RTL provides each process with one interval timer, defined in the <time.h> header file as ITIMER_REAL. This timer decrements in real time and delivers a SIGALRM signal when the timer expires.
0 Indicates success. --1 Indicates an error; errno is set to EINVAL (The value argument specified a time that was too large to handle.)
Gets the login name.
#include <unistd.h>char *getlogin (void);
The getlogin function returns the login name of the user associated with the current session.
x A pointer to a null-terminated string in a static buffer. NULL Indicates an error. Login name is not set.
Returns the file specification associated with a file descriptor.
#include <unixio.h>Function Variants This function also has variants named _getname32 and _getname64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.char *getname (int file_desc, char *buffer, ...);
file_desc
A file descriptor.buffer
A pointer to a character string that is large enough to hold the file specification....
An optional argument that can be either 1 or 0. If you specify 1, the getname function returns the file specification in OpenVMS format. If you specify 0, the getname function returns the file specification in UNIX style format. If you do not specify this argument, the getname function returns the file name according to your current command-language interpreter (CLI). For more information about UNIX style file specifications, see Section 1.4.3.
This function places the file specification into the area pointed to by buffer and returns that address. The area pointed to by buffer should be an array large enough to contain a fully qualified file specification (the maximum length is 256 characters).
x The address passed in the buffer argument. 0 Indicates an error.
A command-line parser that can be used by applications that follow Unix command-line conventions.
#include <unistd.h>(X/OPEN, POSIX-1) #include <stdio.h>
(X/OPEN, POSIX-2) int getopt (int argc, char * const argv[], const char *optstring);
extern char *optarg;
extern int optind, opterr, optopt;
argc
The argument count as passed to main .argv
The argument array as passed to main .optstring
A string of recognized option characters. If a character is followed by a colon, the option takes an argument.
The variable optind is the index of the next element of the argv vector to be processed. It is initialized to 1 by the system, and it is updated by getopt when it finishes with each element of argv. When an element of argv contains multiple option characters, it is unspecified how getopt determines which options have already been processed.The getopt function returns the next option character (if one is found) from argv that matches a character in optstring, if there is one that matches. If the option takes an argument, getopt sets the variable optarg to point to the option-argument as follows:
- If the option was the last character in the string pointed to by an element of argv, then optarg contains the next element of argv, and optind is incremented by 2. If the resulting value of optind is not less than argc, getopt returns an error, indicating a missing option-argument.
- Otherwise, optarg points to the string following the option character in that element of argv, and optind is incremented by 1.
If one of the following is true, getopt returns --1 without changing optind :
- argv[ optind ] is a NULL pointer
- *argv[ optind ] is not the character --
- argv[ optind ] points to the string "--"
Previous Next Contents Index