C语言函数—strncmpi

函数名

strcmp

功 能

串比较

用 法

int strcmp(char *str1, char *str2);

程序例

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

int main(void) 
 { 
    char *buf1 = "aaa", *buf2 = "bbb", *buf3 = "ccc"; 
    int ptr; 

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

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

    return 0; 
 } 
  
  
  

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