c语言把串中的一部分与另一串中的一部分比较, 不管大小写函数

来源:百度文库 编辑:神马文学网 时间:2024/10/04 04:02:06
函数名: strncmpi 
功  能: 把串中的一部分与另一串中的一部分比较, 不管大小写 
用  法: int strncmpi(char *str1, char *str2); 
程序例: 
#include  
#include  
int main(void) 

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