- 字符串比较函数strcmp
- 对两串从左到右逐个ASII码,直到遇到不同字符或者'\0'
- 返回int型整数
- 若字符串1<字符串2,返回负整数
- 若字符串1>字符串2,返回正整数
- 若字符串1==字符串2,返回0
- 字符串比较不能直接用==
#include<stdio.h>
#include<string.h>
int main(){
int i;
char username[10],name[10]="Zhangsan";
gets(username);
if(strcmp(name,username)){
printf("Wrong\n");
}else{
printf("Right\n");
}
puts(username);
return 0;
}