C语言新人 求大神
#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);
}
运行以后,在输入数据界面,只输入一个数就弹出错误窗口了。求解!!
#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);
}
运行以后,在输入数据界面,只输入一个数就弹出错误窗口了。求解!!
...全文
相关推荐
c语言求余数的实例讲解
c语言如何求余数? C语言中求余数直接用双目运算符%,如求a除以b的余数可表示为a%b 注意:C语言中的运算符%的两个操作数必须为整形,不能为浮点型或其他结构体类型,否则编译器会提示错误。 示例代码: #include int main() { int a=5, b=3, c; c=a%b; //将a除以b的余数赋值给c printf("%d",c); return 0; } /* 输出:2 */ 知识点补充: C语言求余数问题 C语言里对于有一些符号是不能直接输出的,因为被C语言占用了。所以有一些符号是需要特殊的方式才能输出的。比如你说的%号,%
求两点距离(C语言)
程序实现求两点距离,C语言入门程序,C语言课程数字计算类小练习。
求和 求平均数——C语言代码
课程的随堂作业,C语言的,用dev就能运行,萌新代码,勿喷,仅仅帮助不想写作业的朋友方便一下,反正老师也不会仔细检查的
c语言实现矩阵求逆程序
c实现矩阵求逆程序。希望对大家有所帮助。
求阶乘 C语言代码
简单源程序,C语言求阶乘的,直接复制粘贴


