strcmp和stricmp的区别?

这个函数stricmp真没接触过以前 好用啊  

strcmp比较区分字母大小写 相当是比较的时候纯粹按照ascii码值来比较从头到尾

而stricmp是不区分字母的大小写的。

 

例子:

#include
#include
int main()
{
 char a[2]="a";
 char b[2]="A";
 //strcmp区分字母大小写
 printf("strcmp:/n");
 int p = strcmp(a,b);
 if(p>0)
 {
  printf("a>A/n");
 }
 else if(p==0)
 {
  printf("a==A/n");
 }
 else
 {
  printf("a }

 //stricmp  不区分字母大小写
 printf("stricmp:/n");
 p = stricmp(a,b);
 if(p>0)
 {
  printf("a>A/n");
 }
 else if(p==0)
 {
  printf("a==A/n");
 }
 else
 {
  printf("a
 }
 return 0;
}

你可能感兴趣的:(strcmp和stricmp的区别?)