#include<stdio.h> #include<string.h>//包含strcmp()函数的定义 void main() { char a[10];//字符串 printf("在学校谁最大?\n"); scanf("%s",a); if(strcmp(a,"校长")==0)//用strcmp()函数比较字符串是否相等 printf("you are right!\n"); else printf("you are wrong!\n"); }
#include <stdio.h> #include < stdlib.h > void main() { char ch[80]; if ( gets ( ch ) == "xiaozhang" ) printf("you are right!\n"); else printf("you are wrong!\n"); system ( "pause" ); }