鱼C论坛

 找回密码
 立即注册
查看: 3880|回复: 3

这段为什么都错了呢???

[复制链接]
发表于 2012-8-20 19:41:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include "stdio.h"
#include"malloc.h"
#define EN sizeof(struct stud)//长度
void print(struct stud *p);//输出动态链表
int n;
struct stud
{
        int shu;
        struct stud *next;
};
void mian()
{
        struct stud *chuang();//创建动态链表
        struct stud *p;
        p = chuang();
        print(p);
}
struct stud *chuang()
{
        struct stud *head;
        struct stud *p1,*p2;
        p1 = p2 = (struct stud *)malloc(EN);
        scanf("%d",p1->shu);
    head = 0;n=0;
        while(p1->shu)
        {
                n++;
                if(n==1)
                {
                        head=p1;
                }
                else
                {
                        p2->next=p1;
                }
                p2=p1;
                p1 = (struct stud *)malloc(EN);
                scanf("%d",p1->shu);
        }
        p2->next = 0;
        return head;
}
void print(struct stud *p)
{
        printf("%d\n",n);
        while(p->shu)
        {
                printf("%d\n",p->shu);
                p = p->next;
        }
}
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-8-20 23:14:48 | 显示全部楼层
哪里错了 我编译没出错啊?
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-8-20 23:57:15 | 显示全部楼层
第11行mian应该是main吧
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-8-21 16:54:25 | 显示全部楼层
LS的好眼力
小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-14 17:53

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表