'fcvt func'에 해당되는 글 1건

  1. 2021.06.24 Watcom C Library Reference : fabs, fclose, fcloseall, fcvt, fdopen, feof

 

 

Watcom C Library Reference : fabs, fclose, fcloseall, fcvt, fdopen, feof

 

 

 

 

fabs

 

Synopsis : #include <math.h> 

              double fabs ( double x );

 


Description : The fabs function computes the absolute value of the argument x.

 

 

Returns : The fabs function returns the absolute value of x.

 

 

See Also : abs, labs

 


Example :

#include <stdio.h> 

#include <math.h>


void main( )

{
    printf( "%f %f\n", fabs (.5), fabs (-.5) );

}

 


produces the following :
0.500000 0.500000

 

Classification : ANSI
Systems : All

 

 

 

 

 

fclose

 

Synopsis : #include <stdio.h> 

              int fclose ( FILE *fp );


Description : The fclose function closes the file fp. If there was any unwritten buffered data for the file, it is written out before the file is closed. Any unread buffered data is discarded. If the associated buffer was automatically allocated, it is deallocated.

 

 

Returns : The fclose function returns zero if the file was successfully closed, or non-zero if any errors were detected. When an error has occurred, errno contains a value indicating the type of error that has been detected.

 

 

See Also : fcloseall, fdopen, fopen, freopen, _fsopen

 


Example :

#include <stdio.h>


void main( )

{
    FILE     *fp;


    fp = fopen( "stdio.h", "r" );

    if( fp != NULL ) {
         fclose( fp );

    }

}

 

Classification : ANSI
Systems : All

 

 

 

 

 

fcloseall

 

Synopsis : #include <stdio.h> 

              int fcloseall( void );

Description : The fcloseall function closes all open stream files, except stdin, stdout, stderr, stdaux, and stdprn. This includes streams created (and not yet closed) by fdopen, fopen and freopen.

 

 

Returns : The fcloseall function returns the number of streams that were closed if no errors were encountered. When an error occurs, EOF is returned.

 

 

See Also : fclose, fdopen, fopen, freopen, _fsopen

 


Example :

#include <stdio.h>


void main( )

{
    printf( "The number of files closed is %d\n", fcloseall() );

}

 

Classification : WATCOM
Systems : All

 

 

 

 

 

fcvt

 

Synopsis : #include <stdlib.h> 

              char *fcvt ( double value, int ndigits, int *dec, int *sign );


Description : The fcvt function converts the floating-point number value into a character string. The parameter ndigits specifies the number of digits desired after the decimal point. The converted number will be rounded to this position.


The character string will contain only digits and is terminated by a null character. The integer pointed to by dec will be filled in with a value indicating the position of the decimal point relative to the start of the string of digits. A zero or negative value indicates that the decimal point lies to the left of the first digit. The integer pointed to by sign will contain 0 if the number is positive, and non-zero if the number is negative.

 

 

Returns : The fcvt function returns a pointer to a static buffer containing the converted string of digits. Note: ecvt and fcvt both use the same static buffer.

 

 

See Also : ecvt, gcvt, printf

 


Example :

#include <stdio.h> 

#include <stdlib.h>


void main( )

{
    char     *str;

    int       dec, sign;


    str = fcvt ( -123.456789, 5, &dec, &sign);

    printf( "str=%s, dec=%d, sign=%d\n", str, dec, sign);

}

 

 
produces the following :
str=12345679, dec=3, sign=-1

 

Classification : WATCOM
Systems : All

 

 

 

 

 

fdopen

 

Synopsis : #include <stdio.h> 

              FILE *fdopen( int handle, const char *mode );

 


Description : The fdopen function associates a stream with the file handle handle which represents an opened file or device. The handle was returned by one of creat, dup, dup2, open, or sopen. The open mode mode must match the mode with which the file or device was originally opened.


The argument mode is described in the description of the fopen function.

 

 

Returns : The fdopen function returns a pointer to the object controlling the stream. This pointer must be passed as a parameter to subsequent functions for performing operations on the file. If the open operation fails, fdopen returns a NULL pointer. When an error has occurred, errno contains a value indicating the type of error that has been detected.

 

 

See Also : creat, dup, dup2, fopen, freopen, _fsopen, open, sopen

 


Example :

#include <stdio.h> 

#include <fcntl.h> 

#include <io.h>


void main( )

{
    int     handle;

    FILE   *fp;

 

    handle = open( "file", O_RDONLY | O_TEXT );

    if( handle != -1 ) {
        fp = fdopen ( handle, "r" );

        if( fp != NULL ) {
            fclose( fp);

        }
        close ( handle );

    }

}

 

Classification : POSIX 1003.1
Systems : All

 

 

 

 

feof

 

Synopsis : #include <stdio.h> 

              int feof( FILE *fp );

 


Description : The feof function tests the end-of-file indicator for the stream pointed to by fp. Because this indicator is set when an input operation attempts to read past the end of the file the feof function will detect the end of the file only after an attempt is made to read beyond the end of the file. Thus, if a file contains 10 lines, the feof will not detect end of file after the tenth line is read; it will detect end of file once the program attempts to read more data.

 

 

Returns : The feof function returns non-zero if the end-of-file indicator is set for fp.

 

 

See Also : clearerr, fopen, freopen, read, ferror, perror

 


Example :

#include <stdio.h>


void main( )

{
    FILE     *fp;

    char     buffer[100];


    fp = fopen( "file", "r" );

    fgets( buffer, sizeof( buffer ), fp);

 

    while( ! feof ( fp ) ) {
        process_record ( buffer );

        fgets ( buffer, sizeof( buffer ), fp);
    }
    fclose( fp );

}

 


void process_record( char *buf )

{

    printf( "%s\n", buf );

}

 

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)

 

 

 

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