# _CP_compare

_CP_compare is equivalent to the `*result* = (*string1* = *string2*)` BASIC statement.

This function has the return codes:

```
-1 string1 < string2
 0 string1 = string2
 1 string1 > string2
```

## Syntax

```
int _CP_compare(int* result, CPSTR* string1, CPSTR* string2)
```

## Example(s)

```
CPSTR * s = _CP_mkstr("a");
CPSTR * t = _CP_mkstr("A");
int i;

_CP_unix_env();
/* default is casing off - print 0 */
_CP_compare(&i,s,t);
printf("%d\n",i);
/* turn casing on - print 1 */
_CP_casing(1);
_CP_compare(&i,s,t);
printf("%d\n",i);
```

## See also

- [C functions overview](https://d3codex.com/cfunctions/c-functions-overview/)

---
Source: https://d3codex.com/cfunctions/cp-compare/ - part of the D3Codex reference.
