StrPtr::operators ==, !=, >, <, <=, >= ( const char * )

Case-sensitive comparison operators between StrPtr and char *.

Virtual?

No

 

Class

StrPtr

 

Arguments

const char *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;

    str1.Set( "This string" );

    printf( "%s", str1.Text());
    if ( str1 == "that string" ) printf( " == " );
    if ( str1 > "that string" )  printf( " > " );
    if ( str1 < "that string" )  printf( " < " );
    printf( "that string" );
    return 0;
}

Executing the preceding code produces the following output:

This string < that string

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