Watcom C Library Reference : _clear87, cleareny, clearerr, _clearscreen, clock
Watcom C Reference/A - B - C 2021. 6. 18. 12:56
WATCOM C Library Reference : _clear87, cleareny, clearerr, _clearscreen, clock
_clear87
Synopsis : #include <float.h>
unsigned int _clear87( void );
Description : The _clear87 function clears the floating-point status word which is used to record the status of 8087/80287/80387/80486 floating-point operations.
Returns : The _clear87 function returns the old floating-point status. The description of this status is found in the <float.h> header file.
See Also : _control87, _fpreset, _status87
Example :
#include <stdio.h>
#include <float.h>
void main( )
{
unsigned int fp_status;
fp_status = clear87( );
printf( "80x87 status =" );
if( fp_status & SW_INVALID ) printf( " invalid" );
if( fp_status & SW_DENORMAL ) printf( " denormal" );
if( fp_status & SW_ZERODIVIDE ) printf( " zero_divide" );
if( fp_status & SW_OVERFLOW ) printf( " overflow" );
if( fp_status & SW_UNDERFLOW ) printf( " underflow" );
if( fp_status & SW_INEXACT ) printf( "inexact_result" );
printf("\n" );
}
Classification : Intel
Systems : All
cleareny
Synopsis : int clearenv( void );
#include <eny.h>
Description : The cleareny function clears the process environment area. No environment variables are
defined immediately after a call to the cleareny function. Note that this clears the PATH, COMSPEC, and TZ environment variables which may then affect the operation of other library functions.
The cleareny function may manipulate the value of the pointer environ.
Returns : The cleareny function returns zero upon successful completion. Otherwise, it will team a non-zero value and set errno to indicate the error.
Errors : When an error has occurred, errno contains a value indicating the type of error that been detected.
Constant | Meaning |
ENOMEM | Not enough memory to allocate a control structure. |
See Also : exec Functions, getenv, putenv, _searchenv, seteny, spawn Functions, system
Example :
The following example clears the entire environment area and sets up a new TZ environment variable.
#include <eny.h>
void main( )
{
cleareny( );
setenv ( "TZ", "EST5EDT", 0 );
}
Classification : POSIX 1003.1
Systems : All
clearerr
Synopsis : #include <stdio.h>
void clearerr( FILE *fp );
Description : The clearerr function clears the end-of-file and error indicators for the stream pointed to by fp. These indicators are cleared only when the file is opened or by an explicit call to the clearerr or rewind functions.
Returns : The clearerr function returns no value.
See Also : feof, ferror, perror
Example :
#include <stdio.h>
void main( )
{
FILE * fp;
int C;
c = 'J';
fp = fopen( "file", "W" );
if( fp != NULL ) {
fputc( c, fp );
if ( ferror( fp ) ) { /* if error */
clearerr( fp ); /* clear the error */
fputc( c, fp); /* and retry it */
}
}
}
Classification : ANSI
Systems : All
_clearscreen
Synopsis : #include <graph.h>
void _FAR _clearscreen( short area );
Description : The clearscreen function clears the indicated area and fills it with the background color. The area argument must be one of the following values:
Constant | Meaning |
_GCLEARSCREEN | area is entire screen |
_GVIEWPORT | area is current viewport or clip region |
_GWINDOW | area is current text window |
Returns : The clearscreen function does not return a value.
See Also : _setbkcolor, _setviewport, _setcliprgn, _settextwindow
Example :
#include <conio.h>
#include <graph.h>
void main( )
{
_setvideomode ( _VRES16COLOR );
_rectangle( _GFILLINTERIOR, 100, 100, 540, 380 );
getch();
_setviewport ( 200, 200, 440, 280 );
_clearscreen( _GVIEWPORT );
getch( );
_setvideomode ( _DEFAULTMODE );
}
Classification : PC Graphics
Systems : DOS, QNX
clock
Synopsis : #include <time.h>
clock_t clock(void);
Description : The clock function returns the number of clock ticks of processor time used by program since the program started executing. This can be converted to seconds by dividing by the value of the macro CLOCKS_PER_SEC.
Returns : The clock function returns the number of clock ticks that have occurred since the program started executing.
See Also : asctime, ctime, difftime, gmtime, localtime, mktime, strftime, time, tzset
Example :
#include <stdio.h>
#include <math.h>
#include <time.h>
void compute( void )
{
int i, j;
double x;
x = 0.0;
for( i = 1; i <= 100; i++ )
for( j = 1; j <= 100; j++ )
x += sqrt( (double) i * j );
printf( "%16.7f\n", x);
}
void main( )
{
clock_t start_time, end_time;
start_time = clock( );
compute( );
end_time = clock( );
printf( "Execution time was %lu seconds\n", (end_time - start_time) / CLOCKS_PER_SEC );
}
Classification : ANSI
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)