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

  1. 2021.11.22 Watcom C Library : tmpnam, tolower, toupper, tzset, ultoa

 

 

Watcom C Library Reference : tmpnam, tolower, toupper, tzset, ultoa

 

 

 

 

tmpnam

 

Synopsis : #include <stdio.h> 

              char *tmpnam( char *buffer );

 


Description : The tmpnam function generates a unique string for use as a valid file name. An internal static buffer is used to construct the filename. Subsequent calls to tmpnam reuse the internal buffer.

 

 

Returns : If the argument buffer is a NULL pointer, tmpnam returns a pointer to an internal buffer containing the temporary file name.  If the argument buffer is not a NULL pointer, tmpnam copies the temporary file name from the internal buffer to the specified buffer and returns a pointer to the specified buffer. It is assumed that the specified buffer is an array of at least L_tmpnam characters.


If the argument buffer is a NULL pointer, you may wish to duplicate the resulting string since subsequent calls to tmpnam reuse the internal buffer.

  char *name1, *name2;
  name1 = strdup( tmpnam( NULL ) ); 

  name2 = strdup( tmpnam( NULL ) );

 

 

See Also : tmpfile

 


Example :

#include <stdio.h>


void main( )

{
    char     filename[ L_tmpnam ];

    FILE     *fp;


    tmpnam( filename );

    fp = fopen( filename, "w+b" );

    /*  .  */

    /*  .  */

    /*  .  */

    fclose( fp );

    remove( filename );

}

 

Classification : ANSI
Systems : All

 

 

 

 

 

 

 

tolower

 

Synopsis : #include <ctype.h> 

              int tolower( int c );

 


Description : The tolower function converts an uppercase letter to the corresponding lowercase letter.

 

 

Returns : The tolower function returns the corresponding lowercase letter when the argument is an uppercase letter; otherwise, the original character is returned.

 

 

See Also : isalnum, isalpha, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit, strlwr, strupr, toupper

 


Example :

#include <stdio.h> 

#include <ctype.h>


char chars[] = {
    'A',
    '5',
    '$',
    'Z'
};


#define SIZE sizeof( chars ) / sizeof( char )


void main( )

{
    int     i;


    for( i = 0; i < SIZE; i++ ) {
        printf( "%c", tolower( chars ( i ) ) );

    }
    printf("\n" );

}

 


produces the following :
a 5 $ z

 

Classification : ANSI
Systems : All

 

 

 

 

 

 

 

toupper

 

Synopsis : #include <ctype.h> 

              int toupper( int c );

 


Description : The toupper function converts a lowercase character to the corresponding uppercase character.

 

 

Returns : The toupper function returns the corresponding uppercase letter when the argument is an lowercase letter; otherwise, the original character is returned.

 

 

See Also :  isalnum, isalpha, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit, strlwr, strupr, tolower

 


Example :

#include <stdio.h> 

#include <ctype.h>


char chars[] = {
    'a',

    '5',

    '$',

    'z'

};

#define SIZE sizeof( chars ) / sizeof( char )


void main( )

{
    int     i;


    for( i = 0; i < SIZE; i++ ) {
        printf( "%c", toupper( chars( i ) ) );

    }
    printf( "\n" );

}

 


produces the following :
A 5 $ Z

 

Classification : ANSI
Systems : All

 

 

 

 

 

 

 

tzset

 

Synopsis : #include <time.h> 

              void tzset( void );

 


Description : The tzset function sets the global variables daylight, timezone and tzname according to the value of the TZ environment variable. The section The TZ Environment Variable describes how to set this variable.


Under Windows NT, tzset also uses operating system supplied time zone information. The TZ environment variable can be used to override this information,


The global variables have the following values after tzset is executed:

 daylihgt  Zero indicates that daylight saving time is not supported in the locale; a non-zero value indicates that daylight saving time is supported in the locale. This variable is cleared/set after a call to the tzset function depending on whether a daylight saving time abbreviation is specified in the TZ environment variable.
 timezone  Contains the number of seconds that the local time zone is earlier than Coordinated Universal Time (UTC) (formerly known as Greenwich Mean Time (GMT)).
 tzname  Two-element array pointing to strings giving the abbreviations for the name of the time zone when standard and daylight saving time are in effect.

 

The time set on the computer with the DOS time command and the DOS date command reflects the local time. The environment variable TZ is used to establish the time zone to which this local time applies. See the section The TZ Environment Variable for a discussion of how to set the time zone.

 


Returns : The function does not return a value.

 

 

See Also : ctime, localtime, mktime, strftime

 


Example :

#include <stdio.h> 

#include <env.h> 

#include <time.h>

 

void print_zone ( )

{
    char     *tz;


    printf( "TZ: %s\n", (tz = getenv( "TZ" ) ) ? tz : "default EST5EDT" ); 

    printf( "  daylight: %d\n", daylight );

    printf( "  timezone: %d\n", timezone );

    printf( "  time zone names: %s %s\n", tzname[0], tzname[1] );

}

 


void main( )

{
    print_zone( );

    setenv( "TZ", "PST8PDT", 1 );

    tzset( );

    print_zone( );

}

 


produces the following :
TZ: default EST5EDT
  daylight: 1

  timezone: 18000
  time zone names: EST EDT

TZ: PST8PDT
  daylight: 1

  timezone: 28800

  time zone names: PST PDT

 

Classification : POSIX 1003.1
Systems : All

 

 

 

 

 

 

 

ultoa

 

Synopsis : #include <stdlib.h> 

              char *ultoa( unsigned long int value, char *buffer, int radix );

 

 

Description : The ultoa function converts the unsigned binary integer value into the equivalent string in base radix notation storing the result in the character array pointed to by buffer. A null character is appended to the result. The size of buffer must be at least 33 bytes when converting values in base 2.

 

 

Returns : The ultoa function returns the pointer to the result.

 

 

See Also : atol, ltoa, strtol, strtoul, utoa

 


Example :

#include <stdio.h> 

#include <stdlib.h>


void print_value( unsigned long int value )

{
    int     base;

    char   buffer[18];


    for( base = 2; base <= 16; base = base + 2 ) {

        printf( "%2d : %s\n", base, ultoa( value, buffer, base ) );

    }

}

 


void main( )

{
    print_value( (unsigned) 12765L );

}

 


produces the following :
2 : 11000111011101 

4 : 3013131 

6 : 135033 

8 : 30735 

10 : 12765 

12 : 7479 

14 : 491b 

16 : 31dd

 

Classification : WATCOM
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 전화카드
,