C语言函数—strncmpi

函数名

strncmp

功 能

串比较

用 法

int strncmp(char *str1, char *str2, int maxlen);

程序例

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

int  main(void) 

{ 
   char *buf1 = "aaabbb", *buf2 = "bbbccc", *buf3 = "ccc"; 
   int ptr; 

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

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

   return(0); 
} 
  
  

如果引用本站的原创文章,请注明原文链接:,本站保留追究责任的权利!