| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 715 人关注过本帖
标题:求助:non-portable pointer assigment in function main
只看楼主 加入收藏
dreamfly827
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-3-30
收藏
 问题点数:0 回复次数:1 
求助:non-portable pointer assigment in function main

哪位能帮我看看?
希望能在源程序上帮我改下
谢谢
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
int data;
struct node *next;
}node;
void insert(node *L,int x)/*在顺序递增的表中插入值为x的元素*/
{
node *u,*p=L;
while(p->next!=NULL&&p->next->data<x)
p=p->next;
if(p->next==NULL||p->next->data<x)
{
u=(node*)malloc(sizeof(node));
u->data=x;
u->next=p->next;
p->next=u;
}
}
create(node *L)/*头插法*/
{
node *u;
int x;
L=(node*)malloc(sizeof(node));
L->next=NULL;
scanf("%d",&x);
while(x!=0)
{
u=(node*)malloc(sizeof(node));
u->data=x;
u->next=L->next;
L->next=u;
scanf("%d",&x);
}

}

main()
{
int i;
node *p=NULL;
p=create(p);
insert(p,10);
printf("Output the list\n");
while(p != NULL)
{
printf("Node %d:%d\n",i++,p->data);
p = p->next;
}

return 0;
}

搜索更多相关主题的帖子: pointer function main assigment 
2006-03-30 18:22
sunnvya
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:1094
专家分:0
注 册:2005-11-23
收藏
得分:0 

#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
int data;
struct node *next;
}node;
void insert(node *&L,int x)/*在顺序递增的表中插入值为x的元素*/
{
node *u,*p=L;
while(p->next!=NULL&&p->next->data<x)
p=p->next;
if(p->next==NULL||p->next->data<x)
{
u=(node*)malloc(sizeof(node));
u->data=x;
u->next=p->next;
p->next=u;
}
}
void create(node *&L)//加引用,C不支持C++支持,用VC++编译
{
node *u;
int x;
L=(node*)malloc(sizeof(node));
L->next=NULL;
scanf("%d",&x);
while(x!=0)
{
u=(node*)malloc(sizeof(node));
u->data=x;
u->next=L->next;
L->next=u;
scanf("%d",&x);
}

}

main()
{
int i=0;//你没有初始化
node *p=NULL;
create(p);//不能写P=create(p)
insert(p,10);
printf("Output the list\n");
while(p != NULL)
{
printf("Node %d:%d\n",i++,p->data);
p = p->next;
}

return 0;
}


http://www. 第二站>>>提供源码下载
2006-03-30 21:50
快速回复:求助:non-portable pointer assigment in function main
数据加载中...
 
   



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

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