# include <iostream.h>
#include <string.h>
struct students {
char num [6];
char name [10];
int greag ;
};
students a[4]=
{
{"af321" , "周润法" , 78 }, {"ad321" , "水均益" , 93 },
{"aa321" , "张朝阳" , 85 }, {"ag321" , "刘翔" , 75 }
};
int search(students s[],int n, students x)//输入一个人名则显示其存在与否!
{
for(int i=0;i<n;i++)
{
if(strcmp(s[i].name,x.name)==0)
return i;
return -1;
}
}
void main()
{
int m=4;
students one_person_name[]="刘翔";//*one_person_name="刘翔";也输不过去!
//如何能将要查找的"人名"作为参数传递到search函数中去??
search(a,m,one_person_name);
}