| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 288 人关注过本帖
标题:线性链表头指针问题
只看楼主 加入收藏
linyiln
Rank: 1
来 自:山东 临沂
等 级:新手上路
帖 子:6
专家分:6
注 册:2012-9-7
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
线性链表头指针问题
#include<stdio.h>
#include<malloc.h>
struct node
{
    ElemType data;
    struct node *next;
} *head;
void initlist()/*创建带头指针的链表*/
{
    head=(struct node*)malloc(sizeof(struct node));
    head->next=NULL;
}
void main()
{
    initlist();

}
此程序为什么不能运行
搜索更多相关主题的帖子: next include void 
2012-10-18 19:34
小糊涂神c30
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:3
帖 子:198
专家分:809
注 册:2012-4-25
收藏
得分:10 
#include<stdio.h>
#include<malloc.h>
struct node
{
    int data;       //ElemType这是什么类型  没见过,是不是模板里面的呀?你没有预定义这种类型 不能使用
    struct node *next;
} *head;
void initlist()/*创建带头指针的链表*/
{
    head=(struct node*)malloc(sizeof(struct node));
    head->next=NULL;
}
void main()
{
    initlist();
}
现在能运行了,不过你这功能还要填很多呀,慢慢思考吧,学链表最好是用笔在纸上画画,模拟一下就可以了!
2012-10-18 19:59
爱闹的娃
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:3
帖 子:265
专家分:975
注 册:2011-10-23
收藏
得分:10 
程序代码:
#include<stdio.h>
#include<malloc.h>
struct node
{
    ElemType data;//LZ应该是看得书上的吧 这里的ElenType 得自己定义出来 如: typedef ElemType int(只要是已经存在的类型就OK);
    struct node *next;
} *head;
void initlist()/*创建带头指针的链表*/
{
    head=(struct node*)malloc(sizeof(struct node));
    head->next=NULL;
}
void main()
{
    initlist();

}
2012-10-18 20:06
快速回复:线性链表头指针问题
数据加载中...
 
   



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

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