The stcmpr() function

The stcmpr() function compares two null-terminated strings.

Syntax

mint stcmpr(s1, s2)
   char *s1, *s2;
s1
A pointer to the first null-terminated string.
s2
A pointer to the second null-terminated string.
Important: s1 is greater than s2 when s1 appears after s2 in the ASCII collation sequence.

Return codes

=0
The two strings are identical.
<0
The first string is less than the second string.
>0
The first string is greater than the second string.

Example

This sample program is in the stcmpr.ec file in the demo directory.
/*
   * stcmpr.ec *

   The following program displays the results of three string
   comparisons using stcmpr().
*/

#include <stdio.h>

main()
{
    printf("STCMPR Sample ESQL Program running.\n\n");

    printf("Executing: stcmpr(\"aaa\", \"aaa\")\n");
    printf("  Result = %d", stcmpr("aaa", "aaa"));  /* equal */
    printf("\nExecuting: stcmpr(\"aaa\", \"aaaa\")\n");
    printf("  Result = %d", stcmpr("aaa", "aaaa")); /* less */
    printf("\nExecuting: stcmpr(\"bbb\", \"aaaa\")\n");
    printf("  Result = %d\n", stcmpr("bbb", "aaaa")); /* greater */

    printf("\nSTCMPR Sample Program over.\n\n");
}

Output

STCMPR Sample ESQL Program running.

Executing: stcmpr("aaa", "aaa")
  Result = 0
Executing: stcmpr("aaa", "aaaa")
  Result = -1
Executing: stcmpr("bbb", "aaaa")
  Result = 1

STCMPR Sample Program over.