第一个易犯错误
char[]类型的字符串不能用==判断,需要用strcmp进行判断
string字符串可以用==进行判断
int main (void){
//char x[2];
string x1;
printf("请选择是读EXCLE还是写!\n");
cin>>(x1);
/*
if(strcmp(x,"读")!=0 && strcmp(x,"写")!=0)){
cout<<"输入非法!!\n";
system("pause");
return 1;
}
*/
if(x1!="读"&& x1!="写"){
cout<<"输入非法!!\n";
system("pause");
return 1;
}
if(x1=="读"){
EXCLE_du();
}else if(x1=="写"){
EXCLE_xie();
}
system("pause");
return 0;
}
总结:如果使用char[]类型的字符串,不能用==进行判断,需要用strcmp,string字符串可以直接使用,char[]类型字符串不能使用= =的原因是,它没有重载= =的操作符,string字符串有。