Borland C++ reference

strcmpi

raw OCR

Compares one string to another, without case sensitivity.

Defined in header <string.h>

Syntax

#include <string.h>
int strcmpi(const char *sl, const char *s2);

Portability

DOSUNIXWindowsANSI CC++ only
■■

Remarks

strcmpi performs an unsigned comparison of si to s2, without case sensitivity (same as stricmp—implemented as a macro).

It returns a value (< 0, 0, or > 0) based on the result of comparing si (or part of it) to s2 (or part of it).

The routine strcmpi is the same, respectively, as stricmp. strcmpi is implemented through a macro in string.h and translates calls from strcmpi to stricmp. Therefore, in order to use strcmpi, you must include the header file string.h for the macro to be available. This macro is provided for compatibility with other C compilers.

Return value

strcmpi returns an int value that is

< 0 if s 2 is less than s2 == 0 if si is the same as s2 > 0 if s2 is greater than s2

See also

Example

#include <string.h>
#include <stdio.h>

int main (void)
{
   char *bufl = "BBB",  *buf2 = "bbb";
   int ptr;
   ptr = strcmpi (buf2, bufl);
   if (ptr > 0)
      printf("buffer 2 is greater  than buffer l\n");
   if (ptr < 0)
      printf ("buffer 2 is less than buffer l\n");
   if (ptr == 0)
      printf("buffer 2 equals buffer  l\n");
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.