Watcom C Library Reference : strerror, strttime, stricmp, _fstricmp, strlen, _fstrlen, strlwr, _fstrlwr, strncat, _fstrncat

 

 

 

 

strerror

 

Synopsis : #include <string.h> 

              char *strerror( int errnum );

 


Description : The strerror function maps the error number contained in errnum to an error message.

 

 

Returns : The strerror function returns a pointer to the error message. The array containing the error string should not be modified by the program. This array may be overwritten by a subsequent call to the strerror function.

 

 

See Also : perror

 


Example :

#include <stdio.h> 

#include <string.h> 

#include <errno.h>


void main( )

{
    FILE     *fp;


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

    if( fp == NULL ) {

        printf( "Unable to open file: %s\n", strerror( errno ) );

    }

}

 

Classification : ANSI
Systems : All

 

 

 

 

 

 

 

strttime

 

Synopsis : #include <time.h> 

              size_t strftime ( char *s,

                               size_t maxsize,

                               const char *format,

                               const struct tm *timeptr );

 

              struct tm {
                  int tm_sec;         /* seconds after the minute --- [0, 61]  */

                  int tm_min;         /* minutes after the hour ------ [0, 59]  */

                  int tm_hour;        /* hours after midnight -------- [0, 23]  */

                  int tm_mday;       /* day of the month ---------- [1, 31]  */ 

                  int tm_mon;        /* months since January ------- [0,11]  */

                  int tm_year;        /* years since 1900                         */

                  int tm_wday;       /* days since Sunday -------- [0, 6]    */ 

                  int tm_yday;        /* days since January 1 ------ [0, 365] */

                  int tm_isdst;        /* Daylight Savings Time flag               */
              };

    

Description : The strftime function formats the time in the argument timeptr into the array pointed to by the argument s according to the format argument.


The format string consists of zero or more directives and ordinary characters. A directive consists of a '%' character followed by a character that determines the substitution that is to take place. All ordinary characters are copied unchanged into the array. No more than maxsize characters are placed in the array. The format directives %D, %h, %n, %r, %t, and %T are from POSIX.

 

 

 Directive  Meaning
 %a  locale's abbreviated weekday name
 %A  locale's full weekday name
 %b  locale's abbreviated month name
 %B  locale's full month name
 %c  locale's appropriate date and time representation
 %d  day of the month as a decimal number (01-31)
 %D  date in the format mm/dd/yy (POSIX)
 %h  locale's abbreviated month name (POSIX)
 %H  hour (24-hour clock) as a decimal number (00-23)
 %I  hour (12-hour clock) as a decimal number (01-12)
 %j  day of the year as a decimal number (001-366)
 %m  month as a decimal number (01-12)
 %M  minute as a decimal number (00-59)
 %n  newline character (POSIX)
 %p  locale's equivalent of either AM or PM
 %r  12-hour clock time (01-12) using the AM/PM notation in the format HH:MM:SS (AMİPM) (POSIX)
 %S  second as a decimal number (00-59)
 %t  tab character (POSIX)
 %T  24-hour clock time in the format HH:MM:SS (POSIX)
 %U  week number of the year as a decimal number (00-52) where Sunday is the first day of the week
 %w  weekday as a decimal number (0-6) where 0 is Sunday
 %W  week number of the year as a decimal number (00-52) where Monday is the first day of the week
 %x  locale's appropriate date representation
 %X  locale's appropriate time representation
 %y  year without century as a decimal number (00-99)
 %Y  year with century as a decimal number
 %Z  timezone name, or by no characters if no timezone exists
 %%  character %


When the %Z directive is specified, the tzset function is called.


Returns : If the number of characters to be placed into the array is less than maxsize, the strftime function returns the number of characters placed into the array pointed to by s not including the terminating null character. Otherwise, zero is returned. When an error has occurred, errno contains a value indicating the type of error that has been detected.

 

 

See Also : setlocale, asctime, clock, ctime, difftime, gmtime, localtime, mktime, time, tzset

 


Example :

#include <stdio.h> 

#include <time.h>


void main( )

{
    time_t   time_of_day;

    char     buffer[80];


    time_of_day = time( NULL );

    strftime( buffer, 80, "Today is %A %B %d, %Y", localtime( &time_of_day ) );

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

}

 


produces the following :
Today is Friday December 25, 1999

 

Classification : ANSI
Systems : All

 

 

 

 

 

 

 

stricmp, _fstricmp

 

Synopsis : #include <string.h> 

              int stricmp( const char *s1, const char *s2 );

              int _fstricmp( const char __far *s1, const char __far *s2 );


Description : The stricmp and _fstricmp functions compare, with case insensitivity, the string pointed to by s1 to the string pointed to by s2. All uppercase characters from s1 and s2 are mapped to lowercase for the purposes of doing the comparison.


The _fstricmp function is a data model independent form of the stricmp function that accepts far pointer arguments. It is most useful in mixed memory model applications.

 

 

Returns : The stricmp and _fstricmp functions return an integer less than, equal to, or greater than zero, indicating that the string pointed to by s1 is less than, equal to, or greater than the string pointed to by s2.

 

 

See Also : strcmp, strcmpi, strncmp, strnicmp

 


Example :

#include <stdio.h> 

#include <string.h>


void main( )

{
    printf( "%d\n", stricmp ( "AbCDEF", "abcdef" ) );

    printf( "%d\n", stricmp( "abcdef", "ABC" ) );

    printf( "%d\n", stricmp ( "abc", "ABCdef" ) );

    printf( "%d\n", stricmp( "Abcdef", "mnopqr" ) );

    printf( "%d\n", stricmp( "Mnopqr", "abcdef" ) );
}

 


produces the following :
0
100
-100 

-12
12

 

Classification : WATCOM
Systems : stricmp - All

             _fstricmp - All

 

 

 

 

 

 

 

strlen, _fstrlen

 

Synopsis : #include <string.h> 

              size_t strlen( const char *s );

              size_t _fstrlen( const char __far *s );

Description : The strlen and _fstrlen functions compute the length of the string pointed to by s.

 

The _fstrlen function is a data model independent form of the strlen function that accepts far pointer arguments. It is most useful in mixed memory model applications.

 

 

Returns : The strlen and _fstrlen functions return the number of characters that precede the terminating null character.

 


Example :

#include <stdio.h> 

#include <string.h>


void main( )

{
    printf( "%d\n", strlen( "Howdy" ) );

    printf( "%d\n", strlen( "Hello world\n" ) );

    printf("%d\n", strlen("") );
}

 


produces the following :

5

12
0

 

Classification : strlen is ANSI, _fstrlen is not ANSI
Systems : strlen - All

             _fstrlen - All

 

 

 

 

 

 

 

strlwr, _fstrlwr

 

Synopsis : #include <string.h> 

              char *strlwr( char *s1 );

              char __far *_fstrlwr( char __far *s1 );

 


Description : The strlwr and _fstrlwr functions replace the string s1 with lowercase characters by invoking the tolower function for each character in the string.


The _fstrlwr function is a data model independent form of the strlwr function. It accepts far pointer arguments and returns a far pointer. It is most useful in mixed memory model applications.

 

 

Returns : The address of the original string s1 is returned.

 

 

See Also : strupr

 


Example :

#include <stdio.h> 

#include <string.h>


char source[] = { "A mixed-case STRING" };


void main( )

{
    printf( "%s\n", source );

    printf( "%s\n", strlwr( source ) );

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

}

 


produces the following :
A mixed-case STRING 

a mixed-case string 

a mixed-case string

 

Classification : WATCOM
Systems : strlwr - All

             _fstrlwr - All

 

 

 

 

 

 

 

 

 

strncat, _fstrncat

 

Synopsis : #include <string.h>

              char *strncat( char *dst, const char *src, size_t n );

              char __far *_fstrncat( char __far *dst, const char __far *src, size_t n );


Description : The strncat and _fstrncat functions append not more than n characters of the string pointed to by src to the end of the string pointed to by dst. The first character of src overwrites the null character at the end of dst. A terminating null character is always appended to the result.

 

The _fstrncat function is a data model independent form of the strncat function. It accepts far pointer arguments and returns a far pointer. It is most useful in mixed memory model applications.

 

 

Returns : The strncat and _fstrncat functions return the value of dst.

 

 

See Also : strcat

 


Example :

#include <stdio.h> 

#include <string.h>


char     buffer[80];


void main( )

{
    strcpy( buffer, "Hello " );

    strncat( buffer, "world", 8 );

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

    strncat( buffer, "*************", 4 );

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

}

 


produces the following :
Hello world 

Hello world****

 

Classification : strncat is ANSI, _fstrncat is not ANSI
Systems : strncat - All

             _fstrncat - 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 전화카드
,