#include "stdio.h"
#include "string.h"
struct student
{
char name[10];
int age;
int score;
};
int main(void)
{
struct student information[3]=
{ {"zhaoxin",22,99},{"lixiao",21,89},{"chenhui",20,92} };
struct student *p_stu=information;
char temp[10];
int i,flag=0;
printf("Enter name:");
scanf("%s",temp);
for(i=0;i<3;i++,p_stu++)
if(strcmp(temp,p_stu->name)==0)
/*strcmp的两个参数不都是地址吗,但是p_stu->name不是地址啊,
为什么运行起来结果是对的,我改成&p_stu->name后运行后也对,
难道两个都行码??? */
{
printf("Yes\n");
flag=1;
break;
}
if(flag==0)
printf("No\n");
return 0;
}