标题:[求助]有个大问题
只看楼主
youniankang
Rank: 1
等 级:新手上路
帖 子:47
专家分:0
注 册:2007-7-18
 问题点数:0 回复次数:1 
[求助]有个大问题

#include<stdio.h>
#include<string.h>
struct student
{
int num;
char name[50];
double scare;
};
void add (struct student stus[])
{
char name[5];
printf("请输入要查找的学员的姓名: \n");
fflush(stdin);
gets(name);
for(int j=0;;j++)
{
if(strcmp(name,stus[j].name)==0)
{
printf("%s:%lf\n",stus[j].name,stus[j].scare);
break;
}
}
}
void main()
{
struct student stus[5]={{1,'lj',60},{2,'ly'70},{3,'hw',80},{4,'yh'90},{5,'lf',95}};
printf("学员信息\n");
printf("==================================================\n");
for(int i=0;i<5;i++)
{
printf("%d\n",stus[i].num);
printf("%d\n",stus[i].name);
printf("%d\n",stus[i].scare);
}
add(stus);
}

错在那里啊

搜索更多相关主题的帖子: include 
2007-08-11 20:27
youniankang
Rank: 1
等 级:新手上路
帖 子:47
专家分:0
注 册:2007-7-18
得分:0 

#include<stdio.h>
#include<string.h>
struct student
{
int num;
char name[50];
double scare;
};
void add (struct student stus[] )
{
int a;
char name[5];
printf("请输入要查找的学员的姓名: \n");
fflush(stdin);
gets(name);
for(int j=0;;j++)
{
if(strcmp(name,stus[j].name)==0)
{
printf("%s:%lf\n",stus[j].name,stus[j].scare);
a++;
if(a==0)
{
printf("没有找到该学员!");
}
break;
}
}
}

void main()
{
struct student stus[5]={{1,"lj",60},{2,"ly",70},{3,"hw",80},{4,"yh",90},{5,"lf",95}};
printf("学员信息\n");
printf("==================================================\n");
for(int i=0;i<5;i++)
{
printf("%d\n",stus[i].num);
printf("%s\n",stus[i].name);
printf("%lf\n",stus[i].scare);
}
add(stus);
}

没找到的那段代码出先了错误
要怎么改啊


2007-08-11 21:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-162001-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.228180 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved