| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1203 人关注过本帖
标题:建立链表,错在哪里?
取消只看楼主 加入收藏
白水而已
Rank: 1
来 自:武汉
等 级:新手上路
帖 子:13
专家分:0
注 册:2008-2-22
收藏
 问题点数:0 回复次数:0 
建立链表,错在哪里?
以下是一个子函数,编译时却出现了很多错误
请问是为什么?
error: expected `while' before "student"
error: expected `(' before "student"
error: expected primary-expression before '*' token
error: expected primary-expression before "void"

error: expected `)' before '{' token
error: expected `;' before '{' token
error: incompatible types in assignment of `const char[7]' to `char[20]'
error: expected primary-expression before '{' token
error: expected `;' before '{' token
error: incompatible types in assignment of `const char[7]' to `char[20]'
error: expected primary-expression before '{' token

error: expected `;' before '{' token
error: incompatible types in assignment of `const char[7]' to `char[20]'
error: expected primary-expression before '{' token
error: expected `;' before '{' token
error: incompatible types in assignment of `const char[7]' to `char[20]'
error: expected primary-expression before '{' token
error: expected `;' before '{' token
error: incompatible types in assignment of `const char[5]' to `char[20]'
error: expected primary-expression before '{' token
error: expected `;' before '{' token
error: invalid conversion from `student*' to `int'

struct student *creat(void)    /*建立动态链表,制作学生成绩单*/
{
       struct student *head;
       struct student *p1,*p2;
       p1=p2=(struct student*)malloc(LEN);/*开辟一个新单元*/
       p1->num=1,p1->name="周润发",p1->score[3]={80.00,74.50,91.00};
       head=NULL;
       for(n=1;n<6;n++)
       {
                       if(n==1)head=p1;
                       else p2->next=p1;
                       p2=p1;
                       p1=(struct student*)malloc(LEN);
                       switch(n)
                       {
                                case 2:p1->num=2,p1->name="刘德华",p1->score[3]={83.00,64.00,75.00};break;
                                case 3:p1->num=3,p1->name="张学友",p1->score[3]={90.00,69.00,81.50};break;
                                case 4:p1->num=4,p1->name="郭富城",p1->score[3]={73.00,62.00,79.00};break;
                                case 5:p1->num=5,p1->name="黎明",p1->score[3]={85.50,84.00,78.00};break;
                       }
       }
       p2->next=NULL;
       return(head);
}
搜索更多相关主题的帖子: 链表 
2008-05-21 11:51
快速回复:建立链表,错在哪里?
数据加载中...
 
   



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

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