Watcom C Library Reference : cos, cosh, cprintf, cputs, creat
Watcom C Reference/A - B - C 2021. 6. 19. 12:58
Watcom C Library Reference : cos, cosh, cprintf, cputs, creat
cos
Synopsis : #include <math.h>
double cos ( double x );
Description : The cos function computes the cosine of x (measured in radians). A large magnitude argument may yield a result with little or no significance.
Returns : The cos function returns the cosine value.
See Also : acos, sin, tan
Example :
#include <math.h>
void main( )
{
double value;
value = cos( 3.1415278 );
}
Classification : ANSI
Systems : All
cosh
Synopsis : #include <math.h>
double cosh ( double x );
Description : The cosh function computes the hyperbolic cosine of x. A range error occurs if the magnitude of x is too large.
Returns : The cosh function returns the hyperbolic cosine value. When the argument is outside the permissible range, the matherr function is called. Unless the default matherr function is replaced, it will set the global variable errno to ERANGE, and print a "RANGE error" diagnostic message using the stderr stream.
See Also : sinh, tanh, matherr
Example :
#include <stdio.h>
#include <math.h>
void main( )
{
printf( "%f\n", cosh (.5) );
}
produces the following:
1.127626
Classification : ANSI
Systems : All
cprintf
Synopsis : #include <conio.h>
int cprintf( const char *format, ...);
Description : The cprintf function writes output directly to the console under control of the argument format. The putch function is used to output characters to the console. The format string is described under the description of the printf function.
Returns : The cprintf function returns the number of characters written.
See Also : _bprintf, fprintf, printf, sprintf, _vbprintf, vcprintf, vfprintf, vprintf, vsprintf
Example :
#include <conio.h>
void main( )
{
char *weekday, *month;
int day, year;
weekday = "Saturday";
month = "April" ;
day = 18;
year = 1987;
cprintf( "%s, %s %, %d\n", weekday, month, day, year );
}
produces the following:
Saturday, April 18, 1987
Classification : WATCOM
Systems : All
cputs
Synopsis : #include <conio.h>
int cputs ( const char *buf );
Description : The cputs function writes the character string pointed to by buf directly to the console using the putch function. Unlike the puts function, the carriage-return and line-teed characters are not appended to the string. The terminating null character is not written.
Returns : The cputs function returns a non-zero value if an error occurs; otherwise, it returns zero. When an error has occurred, errno contains a value indicating the type of error that has been detected.
See Also : fputs, putch, puts
Example :
#include <conio.h>
void main( )
{
char buffer [82];
buffer[0] = 80;
cgets ( buffer );
cputs ( &buffer[2] );
putch ( '\r' );
putch ( '\n' );
}
Classification : WATCOM
Systems : All
creat
Synopsis : #include <sys\types.h>
#include <sys\stat.h>
#include <io.h>
int creat ( const char *path, int mode );
Description : The creat function creates (and opens) a file at the operating system level. It is equivalent to:
open( path, O_WRONLY | O_CREAT | O_TRUNC, mode );
The name of the file to be created is given by path. When the file exists (it must be writeable), it is truncated to contain no data and the preceding mode setting is unchanged.
When the file does not exist, it is created with access permissions given by the mode argument. The access permissions for the file or directory are specified as a combination of bits (defined in the <sys\stat.h> header file).
The following bits define permissions for the owner.
Permission | Meaning |
S_IRWXU | Read, write, execute/search |
S_IRUSR | Read permission |
S_IWUSR | Write permission |
S_IXUSR | Execute/search permission |
The following bits define permissions for the group.
Permission | Meaning |
S_IRWXG | Read, write, execute/search |
S_IRGRP | Read permission |
S_IWGRP | Write permission |
S_IXGRP | Execute/search permission |
The following bits define permissions for the others.
Permission | Meaning |
S_IRWXO | Read, write, execute/search |
S_IROTH | Read permission |
S_IWOTH | Write permission |
S_IXOTH | Execute/search permission |
The following bits define miscellaneous permissions used by other implementations.
Permission | Meaning |
S_IREAD | is equivalent to S_IRUSR (read permission) |
S_IWRITE | is equivalent to S_IWUSR (write permission) |
S_IEXEC | is equivalent to S_IXUSR (execute/search permission) |
All files are readable with DOS; however, it is a good idea to set S_IREAD when read permission is i intended for the file.
Returns : If successful, creat returns a handle for the file. When an error occurs while opening the file, -1 is returned, and errno is set to indicate the error.
Errors : When an error has occurred, errno contains a value indicating the type of error that has been detected.
Constant | Meaning |
EACCES | Access denied because path specifies a directory or a volume ID, or a read-only file. |
EMFILE | No more handles available (too many open files). |
ENOENT | The specified path does not exist or path is an empty string. |
See Also : chsize, close, dup, dup2, eof, exec Functions, filelength, fileno, fstat. isatty, lseek, open, read, setmode, sopen, stat, tell, write, umask
Example :
#include <sys\types.h>
#include <sys\stat.h>
#include <io.h>
void main( )
{
int handle;
handle = creat ( "file", S_IWRITE | S_IREAD);
if( handle != -1 ) {
/* process file */
close( handle );
}
Classification : POSIX 1003.1
Systems : All
This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).
WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)