RAD Studio
ContentsIndex
PreviousUpNext
strcmpi

Header File 

string.h, wchar.h 

Category 

Memory and String Manipulation Routines 

Prototype 

int strcmpi(const char *s1, const char *s2); 

int _wcscmpi(const wchar_t *s1, const wchar_t *s2); 

Description 

Compares one string to another, without case sensitivity. 

strcmpi performs an unsigned comparison of s1 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 s1 (or part of it) to s2 (or part of it). 

The routine strcmpi is the same 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  

less than s2 
< 0 
the same as s2 
== 0 
greater than s2 
> 0 

Example

/* strncmpi example */ 
#include <string.h>
#include <stdio.h>
int main(void)
{
   char *buf1 = "BBB", *buf2 = "bbb";
   int ptr;
   ptr = strcmpi(buf2, buf1);
   if (ptr > 0)
      printf("buffer 2 is greater than buffer 1\n");
   if (ptr < 0)
      printf("buffer 2 is less than buffer 1\n");
   if (ptr == 0)
      printf("buffer 2 equals buffer 1\n");
   return 0;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
strcmpi 
 
 
 
_wcscmpi 
 
 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!