C语言新人 求大神

细水丿 细水丿 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define LISTSIZE 10
typedef struct LinkNode{
int data;
struct LinkNode *next;
}LN;
LN *InitList()
{
LN *List, *p;
int n=0;

List=(LN *)malloc(sizeof(LN));
if(!List) { printf("ERROR!\n"); exit(0);}
List->next=NULL;
while(n<LISTSIZE){
p=(LN *)malloc(sizeof(LN));
p->next=List->next;
List->next=p;
n++;
}
return List;
}
void IOputData(LN *List)
{
char ch;
LN *p=NULL;
int n=0;

p=List->next;
printf("input data:");
while(p){
scanf("%d", &p->data);
p=p->next;
n++;
}
printf("please press any key to continue~\n");
ch=getch();
p=List->next;
while(p){
printf("%d", p->data);
p=p->next;
}
}
main()
{
LN *List=NULL;

List=InitList();
IOputData(&List);
}



运行以后,在输入数据界面,只输入一个数就弹出错误窗口了。求解!!
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
细水丿
C语言 70,038 成员 243,237 内容