结构数组问题

[复制链接]
查看11 | 回复3 | 2010-6-3 10:55:55 | 显示全部楼层 |阅读模式
#include
struct men
{
char num[5];
char name[10];
int age[5];
}
all[20]={
{"001","王二",24},
{"002","张三",23},
{"003","李四",24},
};
int find(men t[],int n,char *s)
{
int i;
for(i=0;in-1)

printf("No found not deleted\n");
else

{

print(t);

printf("Are you sure delete it(1/0)\n");
scanf("%d",&ch);
if(ch==1)

{

for(j=i+1;j#include struct men{ char num[5];char name[10];int age[5];}all[20]={ {"001","王二",24},{"002","张三",23}, {"003","李四",24}, }; int find(men t[],int n,char *s){
int i; for(i=0;i<n;i++) {
if(strcmp(s,t.num)==0)
return i; }
return i;
回复

使用道具 举报

千问 | 2010-6-3 10:55:55 | 显示全部楼层
typedef struct men
回复

使用道具 举报

千问 | 2010-6-3 10:55:55 | 显示全部楼层
把参数中的"men t[]"改为“struct men t[]"就行了。 还有LS说的。
回复

使用道具 举报

千问 | 2010-6-3 10:55:55 | 显示全部楼层
修改函数:printf("Num:%-10s\n",t.num);printf("Name:%-20s\n",t.name); printf("Age:%-10d\n",t.age);//t应该是t吧,另外前面还要加个if(i<n)的判断,以下类推
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行