Watcom C Library Reference : strncmp, _fstrncmp, strncpy, _fstrncpy, strnicmp, _fstrnicmp, strnset, _fstrnset, strpbrk, _fstrpbrk, 

 

 

 

 

strncmp, _fstrncmp

 

Synopsis : #include <string.h> 

              int strncmp( const char *s1, const char *s2, size_t n );

              int _fstrncmp( const char __far *s1, const char __far *s2, size_t n );

 


Description : The strncmp and _fstrncmp functions compare not more than n characters from the string pointed to by s1 to the string pointed to by s2.


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

 

 

Returns : The strncmp and _fstrncmp 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, stricmp, strnicmp

 


Example :

#include <stdio.h> 

#include <string.h>


void main( )

{
    printf( "%d\n", strncmp( "abcdef", "abcDEF", 10 ) );

    printf( "%d\n", strncmp( "abcdef", "abcDEF", 6 ) );

    printf( "%d\n", strncmp( "abcdef", "abcDEF", 3 ) );

    printf( "%d\n", strncmp( "abcdef", "abcDEF", 0 ) );

}

 


produces the following :
1

1

0

0

 

Classification : strncmp is ANSI, _fstrncmp is not ANSI
Systems : strncmp - All 

             _fstrncmp - All

 

 

 

 

 

 

 

strncpy, _fstrncpy

 

Synopsis : #include <string.h> 

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

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

 


Description : The strncpy and _fstrncpy functions copy no more than n characters from the string pointed to by src into the array pointed to by dst. Copying of overlapping objects is not guaranteed to work properly. See the memmove function if you wish to copy objects that overlap.


If the string pointed to by src is shorter than n characters, null characters are appended to the copy in the array pointed to by dst, until n characters in all have been written. If the string pointed to by src is longer than n characters, then the result will not be terminated by a null character.


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

 

 

Returns : The strncpy and _fstrncpy functions return the value of dst.

 

 

See Also : strcpy, strdup

 


Example :

#include <stdio.h> 

#include <string.h>


void main( )

{
    char     buffer[15];


    printf( "%s\n", strncpy( buffer, "abcdefg", 10 ) );

    printf( "%s\n", strncpy( buffer, "1234567", 6) );

    printf( "%s\n", strncpy( buffer, "abcdefg", 3 ) );

    printf( "%s\n", strncpy( buffer, "*******", 0) );

}

 


produces the following :
abcdefg

123456g

abc456g

abc456g

 

Classification : strncpy is ANSI, _fstrncpy is not ANSI
Systems : strncpy - All

             _fstrncpy - All

 

 

 

 

 

 

 

strnicmp, _fstrnicmp

 

Synopsis : #include <string.h> 

              int strnicmp( const char *s1, const char *s2, size_t len );

              int _fstrnicmp( const char __far *s1, const char __far *s2, size_t len );

 


Description : The strnicmp and _fstrnicmp functions compare, without case sensitivity, the string pointed to by s1 to the string pointed to by s2, for at most len characters.


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

 

 

Returns : The strnicmp and _fstrnicmp 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, stricmp, strncmp

 


Example :

#include <stdio.h> 

#include <string.h>


void main( )

{
    printf( "%d\n", strnicmp( "abcdef", "ABCXXX", 10 ) );

    printf( "%d\n", strnicmp( "abcdef", "ABCXXX", 6 ) );

    printf( "%d\n", strnicmp( "abcdef", "ABCXXX", 3 ) );

    printf( "%d\n", strnicmp( "abcdef", "ABCXXX", 0) );

}

 


produces the following :
-20 

-20
0

0

 

Classification : WATCOM
Systems : strnicmp - All

             _fstrnicmp - All

 

 

 

 

 

 

 

strnset, _fstrnset

 

Synopsis : #include <string.h> 

              char *strnset( char *s1, int fill, size_t len );

              char __far *_fstrnset( char -_far *s1, int fill, size_t len );

 


Description : The strnset and _fstrnset functions fill the string s1 with the value of the argument fill, converted to be a character value. When the value of len is greater than the length of the string, the entire string is filled. Otherwise, that number of characters at the start of the string are set to the fill character.


The _fstrnset function is a data model independent form of the strnset 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 : strset

 


Example :

#include <stdio.h> 

#include <string.h>


char     source[] = { "A sample STRING" };


void main( )

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

    printf( "%s\n", strnset( source, '=' , 100 ) );

    printf( "%s\n", strnset( source, '*', 7 ) );

}

 


produces the following :
A sample STRING 

=============== 

*******========

 

 

Classification : WATCOM
Systems : strnset - All

             _fstrnset - All

 

 

 

 

 

 

 

strpbrk, _fstrpbrk

 

Synopsis : #include <string.h>

              char *strpbrk( const char *str, const char *charset );

              char __far *_fstrpbrk( const char __far *str, const char __far *charset );

 


Description : The strpbrk and _fstrpbrk functions locate the first occurrence in the string pointed to by str of any character from the string pointed to by charset.


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

 

 

Returns : The strpbrk and _fstrpbrk functions return a pointer to the located character, or NULL if no character from charset occurs in str.

 

 

See Also : strchr, strrchr, strtok

 


Example :

#include <stdio.h> 

#include <string.h>


void main( )

{
    char *p = "Find all vowels";


    while( p != NULL ) {
        printf( "%s\n", p );

        p = strpbrk( p+1, "aeiouAEIOU" );

    }

}

 


produces the following :
Find all vowels 

ind all vowels 

all vowels 

owels 

els

 

Classification : strpbrk is ANSI, _fstrpbrk is not ANSI
Systems : strpbrk - All

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