请各位高手帮我看看着个程序为什么这里错了

来源:百度知道 编辑:UC知道 时间:2024/05/26 01:20:11
以下是我设计的一个数据管理系统的C程序,
在连接时出现"improper use of a typedef symbol in function array"这样的报错,
不知道我的array排序函数为什么错了,
哪位高手能解释下,顺便看下还会出现其他什么问题,帮我修改修改,
拜托了!回答满意一定加分!(*^_^*)
由于字数限制,只能写这么多了...
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <conio.h>
#define SIZE 20
/* 定义结构体 */
typedef struct people
{char name[20] ,addr[15],sex[10],sta[10],id[20];
int age;
struct people *next;
}people;
struct people peop[SIZE];
/* 逐项输出链表中的内容 */
void view(struct people * head)
{struct people * p;
p = head;
while (p != NULL)
{printf("name:%20s\naddr:%15s\nsex:%10s\nsta:%10s\nid:%20s\nage:%3d\n", p->name, p->addr,p->sex, p->sta,p->id, p->age);
p=p->next;
}
}
/*定义排序函数*/
void array(struct people* head)
{people temp;
int n=0,i,j;<

那就把
people temp;
这行改为struct people temp;

链表和数组没有必要同时用,
要不你的struct里不加next,
要不你就别定义peop[] .

假设你用链表
void array(struct people head)
{
struct people temp,p,q;
for(p=head;p!=NULL;p=p->next)
for(q=p->next;q!=NULL;q=q->next)
{
if(p.age>q.age)
{
//将链表中的两项交换位置
}
}
}