StrPtr::XCompare( const StrPtr & )

Case sensitive comparison of two StrPtrs.

Virtual?

No

 

Class

StrPtr

 

Arguments

const StrPtr &s

the StrPtr to compare this one with

Returns

int

zero if identical, nonzero if different

Notes

StrPtr::XCompare() is a wrapper for strcmp(). Its return value, if nonzero, indicates which of the two strings is "greater" in the ASCII sense.

See also

StrPtr::CCompare() StrPtr::Compare()

Example

#include <stdhdrs.h>
#include <strbuf.h>

int main( int argc, char **argv )
{
    StrBuf str1, str2, str3;

    str1.Set( "abc" );
    str2.Set( "Abc" );
    str3.Set( "xyz" );

    if ( str1.XCompare( str2 ) == 0 )
        printf( "%s == %s\n", str1.Text(), str2.Text() );
    else
        printf( "%s != %s\n", str1.Text(), str2.Text() );

    if ( str1.XCompare( str3 ) == 0 )
        printf( "%s == %s\n", str1.Text(), str3.Text() );
    else
        printf( "%s != %s\n", str1.Text(), str3.Text() );

    return 0;
}

Executing the preceding code produces the following output:

abc != Abc
abc != xyz