Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2025.2

# StrPtr::Compare( const StrPtr & )

Comparison of two `StrPtr`s, with case sensitivity based on client platform.

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::Compare()` is a wrapper for `zstrcmp()`. Its return value, if nonzero, indicates which of the two strings is "greater" in the ASCII sense.

## See also

- `StrPtr::CCompare()`

- `StrPtr::XCompare()`

## Example

Copy

    #include &lt;stdhdrs.h&gt;
    #include &lt;strbuf.h&gt;

    int main( int argc, char **argv )
    {
        StrBuf str1, str2, str3;
        str1.Set( "abc" );
        str2.Set( "Abc" );
        str3.Set( "xyz" );

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

        if ( str1.Compare( 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 on Windows:

    abc == Abc
    abc != xyz

and on Unix

    abc != Abc
    abc != xyz

Your search for returned results