background image

    ptr = strcmp(buf2, buf1); 
    if (ptr > 0) 
       printf("buffer 2 is greater than buffer 1\n"); 
    else 
       printf("buffer 2 is less than buffer 1\n"); 

    ptr = strcmp(buf2, buf3); 
    if (ptr > 0) 
       printf("buffer 2 is greater than buffer 3\n"); 
    else 
       printf("buffer 2 is less than buffer 3\n"); 

    return 0; 
 } 
  
  
  

函数名: strncmpi 

  

功 能: 将一个串中的一部分与另一个串比较, 

 

不管大小写

  

用 法: int strncmpi(char *str1, char *str2, unsigned maxlen); 
程序例: 

#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;