Watcom C Libraray Reference : abort, abs, access 

 

 

abort

 

Synopsis : #include <stdlib.h>

              void abort( void );

Description : The abort function raises the signal SIGABRT. The default action for SIGABRT is to terminate program execution, returning control to the process that started the calling program (usually the operating system). The status unsuccessful termination is returned to the invoking process by means of the function call raise (SIGABRT). Under DOS and OS/2. the status value is 3.

Returns : The abort function does not return to its caller.

See Also : atexit, _bget cmd, exec Functions, exit, _exit, get cmd, getenv, main, onexit, putenv, spawn Functions, system

Example :
#include <stdlib.h>
void main( )

{
    int major_error = 1;
    if( major_error )

    {
        abort();

    }

}

Classification : ANSI
Systems : All

 

 

 

 

abs


Synopsis :  #include <stdlib.h>

                int abs( int j );

Description : The abs function returns the absolute value of its integer argument j.

 

Returns : The abs function returns the absolute value of its argument.

See Also : fbas, labs

Example :

#include <stdio.h>
#include <stdlib.h>
void main( )

{
    printf( "%d %d %d \n", abs(-5), abs(0), abs(5) );
}

 

produces the following :

5  0  5 

Classification : ANSI
Systems : All



 

access

 

Synopsis :  #include <io.h> 

               int access ( const char *path, int mode );


Description : The access function determines if the file or directory specified by path exists and if it can be accessed with the file permission given by mode.

 

When the value of mode is zero, only the existence of the file is verified. The read and/or write permission for the file can be determined when mode is a combination of the bits:

 

Bit        Meaning
R_OK     test for read permission
W_OK    test for write permission
X_OK     test for execute permission

F_OK     test for existence of file

 

With DOS, all files have read permission; it is a good idea to test for read permission anyway, since a later versionof DOS may support write-only files.

 


Returns : The access returns zero if the file or directory exists and can be accessed with the specifica mode. Otherwise, -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 the file's permission does not allow the specified access.
         ENOENT   Path or file not found.

 

See Also : chmod, fstat, open, sopen, stat


Example :

#include <stdio.h> 

#include <stdlib.h> 

#include <io.h>
void main( int argc, char *argv[ ] )
{
    if( argc != 2 ) {
        fprintf( stderr, "Use: check <filename>\n" );

        exit( 1 );

    }

    if( access ( argv[1], F_OK ) == 0 ) {
        printf("%s exists\n", argv[1] );

    } else {
        printf("%s does not exist\n", argv[1] );

        exit( EXIT_FAILURE );

    }
    if( access ( argv[1], R_OK ) == 0 ) {
        printf("%s is readable\n", argv[1] );

    }
    if( access ( argv[1], W_OK ) == 0 ) {
        printf("%s is writeable\n", argv[1] );

    }
    if( access ( argv[1], X_OK ) == 0 ) {
        printf("%s is executable\n", argv[1] );

    }
    exit( EXIT_SUCCESS );

}

 

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)

 

 

728x90
반응형
Posted by 전화카드
,