Previous | Contents | Index |
Gives a new name to an existing file.
#include <stdio.h>int rename (const char *old_file_spec, const char *new_file_spec);
old_file_spec
A pointer to a string that is the existing name of the file to be renamed.new_file_spec
A pointer to a string that is to be the new name of the file.
If you try to rename a file that is currently open, the behavior is undefined. You cannot rename a file from one physical device to another. Both the old and new file specifications must reside on the same device.If the new_file_spec does not contain a file extension, the file extension of old_file_spec is used. To rename a file to have no file extension, new_file_spec must contain a period (.) For example, the following renames SYS$DISK:[]FILE.DAT to SYS$DISK:[]FILE1.DAT:
rename("file.dat", "file1");However, the following renames SYS$DISK:[]FILE.DAT to SYS$DISK:[]FILE1:
rename("file.dat", "file1.");
Note
Because the rename function does special processing of the file extension, the caller must be careful when specifying the name of the renamed file in a call to a C Run-Time Library function that accepts a file-name argument. For example, after the following call to the rename function, the new file should be opened as fopen("bar.dat",...) :
rename("foo.dat", "bar");The rename function is affected by the setting of the DECC$RENAME_NO_INHERIT and DECC$RENAME_ALLOW_DIR feature logicals as follows:
- DECC$RENAME_NO_INHERIT provides more UNIX compliant behavior in rename , and affects whether or not the new name for the file inherits anything (like file type) from the old name or must be specified completely.
- DECC$RENAME_ALLOW_DIR lets you choose between the previous OpenVMS behavior of allowing the renaming of a file from one directory to another, or the more UNIX compliant behavior of not allowing the renaming of a file to a directory.
See the DECC$RENAME_NO_INHERIT and DECC$RENAME_ALLOW_DIR descriptions in Section 1.6 for more information.
0 Indicates success. - 1 Indicates failure. The function sets errno to one of the following values:
- EISDIR -- The new argument points to a directory, and the old argument points to a file that is not a directory.
- EEXIST -- The new argument points to a directory that already exists.
- ENOTDIR -- The old argument names a directory, and new argument names a non-directory file.
Sets the file to its beginning.
#include <stdio.h>void rewind (FILE *file_ptr); (ISO POSIX-1)
int rewind (FILE *file_ptr); (HP C EXTENSION)
file_ptr
A file pointer.
The rewind function is equivalent to fseek (file_ptr, 0, SEEK_SET) . You can use the rewind function with either record or stream files.A successful call to rewind clears the error indicator for the file.
The ANSI C standard defines rewind as not returning a value; therefore, the function prototype for rewind is declared with a return type of void . However, since a rewind can fail, and since previous versions of the HP C RTL have declared rewind to return an int , the code for rewind does return 0 on success and - 1 on failure.
See also fseek .
Resets the position of the specified directory stream to the beginning of a directory.
#include <dirent.h>void rewinddir (DIR *dir_pointer);
dir_pointer
A pointer to the dir structure of an open directory.
The rewinddir function resets the position of the specified directory stream to the beginning of the directory. It also causes the directory stream to refer to the current state of the corresonding directory, the same as using the opendir function. If the dir_pointer argument does not refer to a directory stream, the effect is undefined.The type DIR , defined in the <dirent.h> header file, represents a directory stream. A directory stream is an ordered sequence of all the directory entries in a particular directory. Directory entries represent files.
See also opendir .
Searches for a character in a string.
#include <strings.h>Function Variants The rindex function has variants named _rindex32 and _rindex64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.10 for more information on using pointer-size-specific functions.char *rindex (const char *s, int c);
s
The string to search.c
The character to search for.
The rindex function is identical to the strchr function, and is provided for compatibility with some UNIX implementations.
Rounds its argument to an integral value according to the current IEEE rounding direction specified by the user.
#include <math.h>double rint (double x);
float rintf (float x,);
long double rintl (long double x);
x
A real number.
The rint functions return the nearest integral value to x in the direction of the current IEEE rounding mode specified on the /ROUNDING_MODE command-line qualifier.If the current rounding mode rounds toward negative Infinity, then rint is identical to floor . If the current rounding mode rounds toward positive Infinity, then rint is identical to ceil .
If |x| = Infinity, rint returns x.
n The nearest integral value to x in the direction of the current IEEE rounding mode. NaN x is NaN; errno is set to EDOM.
Removes a directory file.
#include <unistd.h>int rmdir (const char *path);
path
A directory pathname.
The rmdir function removes a directory file whose name is specified in the path argument. The directory is removed only if it is empty.If path names a symbolic link, then rmdir fails and sets errno to ENOTDIR.
When using OpenVMS format names, the path argument must be in the form directory.dir.
0 Indicates success. - 1 An error occurred; errno is set to indicate the error.
Determines the lowest virtual address that is not used with the program.
#include <unistd.h>void *sbrk (long int incr);
incr
The number of bytes to add to the current break address.
The sbrk function adds the number of bytes specified by its argument to the current break address and returns the old break address.When a program is executed, the break address is set to the highest location defined by the program and data storage areas. Consequently, sbrk is needed only by programs that have growing data areas.
sbrk(0) returns the current break address.
x The old break address. ( void *)( - 1) Indicates that the program is requesting too much memory.
Unlike other C library implementations, the HP C RTL memory allocation functions (such as malloc ) do not rely on brk or sbrk to manage the program heap space. Consequently, on OpenVMS systems, calling brk or sbrk can interfere with memory allocation routines. The brk and sbrk functions are provided only for compatibility purposes.
Returns the exponent of a floating-point number.
#include <math.h>double scalb (double x, double n);
float scalbf (float x, float n);
long double scalbl (long double x, long double n);
x
A nonzero floating-point number.n
An integer.
The scalb functions return x*(2**n) for integer n.
x On successful completion, x*(2** n) is returned. ±HUGE_VAL On overflow, scalb returns ±HUGE_VAL (according to the sign of x) and sets errno to ERANGE. 0 Underflow occurred; errno is set to ERANGE. x x is ±Infinity. NaN x or n is NaN; errno is set to EDOM.
Performs formatted input from the standard input ( stdin ), interpreting it according to the format specification. See Chapter 2 for information on format specifiers.
#include <stdio.h>int scanf (const char *format_spec, ...);
format_spec
Pointer to a string containing the format specification. The format specification consists of characters to be taken literally from the input or converted and placed in memory at the specified input sources. For a list of conversion characters, see Chapter 2....
Optional expressions that are pointers to objects whose resultant types correspond to conversion specifications given in the format specification.If no conversion specifications are given, you can omit these input pointers. Otherwise, the function call must have at least 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.
x The number of successfully matched and assigned input items. EOF Indicates that a read error occurred prior to any successful conversions.The function sets errno . For a list of errno values set by this function, see fscanf .
Perform a scanf on the window. The scanw function acts on the stdscr window.
#include <curses.h>int scanw (char *format_spec, ...);
int wscanw (WINDOW *win, char *format_spec, ...);
win
A pointer to the window.format_spec
A pointer to the format specification string....
Optional expressions that are pointers to objects whose resultant types correspond to conversion specifications given in the format specification. If no conversion specifications are given, you may omit these input pointers.Otherwise, the function call must have at least 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.
The formatting specification (format_spec) and the other arguments are identical to those used with the scanf function.The scanw and wscanw functions accept, format, and return a line of text from the terminal screen. For more information, see the scrollok and scanf functions.
OK Indicates success. ERR Indicates that the function makes the screen scroll illegally or that the scan was unsuccessful.
Moves all the lines on the window up one line. The top line scrolls off the window and the bottom line becomes blank.
#include <curses.h>int scroll (WINDOW *win);
win
A pointer to the window.
OK Indicates success. ERR Indicates an error.
Sets the scroll flag for the specified window.
#include <curses.h>scrollok (WINDOW *win, bool boolf);
win
A pointer to the window.boolf
A Boolean TRUE or FALSE value. If boolf is FALSE, scrolling is not allowed. This is the default setting. The bool type is defined in the <curses.h> header file as follows:
#define bool int
Initializes a 48-bit random-number generator.
#include <stdlib.h>unsigned short *seed48 (unsigned short seed_16v[3]);
seed_16v
An array of three unsigned short int s that form a 48-bit seed value.
The seed48 function initializes the random-number generator. You can use this function in your program before calling the drand48 , lrand48 , or mrand48 functions. (Although it is not recommended practice, constant default initializer values are supplied automatically if you call drand48 , lrand48 , or mrand48 without calling an initialization function).The seed48 function works by generating a sequence of 48-bit integer values, Xi, according to the linear congruential formula:
Xn+1 = (aXn+c)mod m n > 0The argument m equals 248 , so 48-bit integer arithmetic is performed. Unless you invoke the lcong48 function, the multiplier value a and the addend value c are:
a = 5DEECE66D16 = 2736731631558 c = B16 = 138The initializer function seed48 :
- Sets the value of Xi to the 48-bit value specified in the array pointed to by seed_16v.
- Returns a pointer to a 48-bit internal buffer that contains the previous value of Xi, used only by seed48 .
The returned pointer allows you to restart the pseudorandom sequence at a given point. Use the pointer to copy the previous Xi value into a temporary array. To resume where the original sequence left off, you can call seed48 with a pointer to this array.
See also drand48 , lrand48 , and mrand48 .
x A pointer to a 48-bit internal buffer.
Sets the position of a directory stream.
#include <dirent.h>void seekdir (DIR *dir_pointer, long int location);
dir_pointer
A pointer to the dir structure of an open directory.location
The number of an entry relative to the start of the directory.
The seekdir function sets the position of the next readdir operation on the directory stream specified by dir_pointer to the position specified by location. The value of location should be returned from an earlier call to telldir.If the value of location was not returned by a call to the telldir function, or if there was an intervening call to the rewinddir function on this directory stream, the effect is unspecified.
The type DIR , defined in the <dirent.h> header file, represents a directory stream. A directory stream is an ordered sequence of all the directory entries in a particular directory. Directory entries represent files. You can remove files from or add files to a directory asynchronously to the operation of the readdir function.
See readdir , rewinddir , and telldir .
Activate the video display attribute attr within the window. The setattr function acts on the stdscr window.
#include <curses.h>int setattr (int attr);
int wsetattr (WINDOW *win, int attr);
win
A pointer to the window.attr
One of a set of video display attributes, which are blinking, boldface, reverse video, and underlining, and are represented by the defined constants _BLINK, _BOLD, _REVERSE, and _UNDERLINE, respectively. You can set multiple attributes by separating them with a bitwise OR operator (|) as follows:
setattr(_BLINK | _UNDERLINE);
The setattr and wsetattr functions are specific to HP C for OpenVMS Systems and are not portable.
OK Indicates success. ERR Indicates an error.
Previous | Next | Contents | Index |