首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

c语言链表源程序,求各位大牛帮小弟找找错解决方案

2012-03-21 
c语言链表源程序,求各位大牛帮小弟找找错# include stdio.h# include string.h# define NUM 10struct

c语言链表源程序,求各位大牛帮小弟找找错
# include <stdio.h>
# include <string.h>
# define NUM 10

struct student 
{
int num;
int age;
char name[20];
struct student *next;
}

int main(void)
{
int i;
int e;
int *head, *p;
struct student st[NUM];

printf("Please input Name Num Age\n");

for(i = 0; i < NUM; i++)
{
fgets(st[i].name, NUM, stdin);

scanf(" %d %s %d", &st[i].num, &st[i].age);
}

head = &st[0].num;
p = head;
st[NUM-1].next = NULL;

printf("Please input a number: ");
scanf(" %d", &e);

for(i = 0; i < NUM, p != NULL; i++)
{
if(e == st[i].num)
{
printf("The nunber, name and age is %d, %s, %d\n",st[i].num,
st[i].name, st[i].age );
}
else
{
p -> next = st[i+1].num;
}
}

return 0;
}

[解决办法]
1.结构体struct定以后要使用;
struct student
{
int num;
int age;
char name[20];
struct student *next;
};

2.
*p = st[i+1].num;


热点排行