StrPtr::operators ==, !=, >, <, <=, >= ( const StrPtr & )

Case-sensitive comparison operators between StrPtr and StrPtr.

Virtual?

No

 

Class

StrPtr

 

Arguments

const StrPtr & buf

the string to compare with

Returns

int

zero if the comparison is false, nonzero if true.

Notes

These operators are typically used in simple comparisons between StrPtrs, such as to see whether two StrPtrs contain the same string, or whether one is greater than the other, ASCII-wise. The comparison is always case-sensitive.

Example

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

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

    str1.Set( "This string" );
    str2.Set( "that string" );

    printf( "%s", str1.Text());
    if ( str1 == str2 ) printf( " == " );
    if ( str1 > str2 )  printf( " > " );
    if ( str1 < str2 )  printf( " < " );
    printf( "%s\n", str2.Text() );
    return 0;
}

Executing the preceding code produces the following output:

This string < that string

(Note that “t” > “T” in ASCII.)