Borland C++ reference

strncmpi

raw OCR

Compares a portion of one string to a portion of another, without case sensitivity.

Defined in header <string.h>

Syntax

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

Portability

DOSUNIXWindowsANSI CC++ only
■■

Remarks

strncmpi performs a signed comparison of si to s2, for a maximumlength

of n bytes, starting with the first character in each string and continuing with subsequent characters until the corresponding characters differ or until n characters have been examined. The comparison is not case sensi-tive, (strncmpi is the same as strnicmp—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 routines strnicmp and strncmpi are the same; strncmpi is implemented through a macro in string.h that translates calls from strncmpi to strnicmp. Therefore, in order to use strncmpi, 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

strncmpi returns an int value that is

< 0 if s3 is less than s2 -- 0 if si is the same as s2 > 0 if s2 is greater than s2

Example

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

int main (void)
{
   char *bufl =  "BBBccc", *buf2 = "bbbccc";
   int ptr;
   ptr = strncmpi (buf2,buf1,3);
   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.