回复 19楼 yuccn
void sex(){
char ch[4] = {0};
char a[4]="男";
char b[4]="女";
R: printf("请输入:");
scanf("%s",ch);//R
if(strcmp(ch,a)==0||strcmp(ch,b)==0)
{
printf("%s\n",ch);
}
else printf("输入有误请重新输入\n"); goto R;
}这个就是对的函数,
不要为&&||而争辩了
#include <stdio.h> #include <string.h> int main() { char buf[5]; char *MALE = "男"; char *FEMALE = "女"; puts("Please input"); scanf("%s", buf); if(strcmp(buf, MALE) == 0 || strcmp(buf, FEMALE) == 0) { printf("%s\n", buf); } else puts("Error input"); return 0; }