编程时出现错误,求解决方案
出现什么错误代码ox80070002
这情况初次碰到,不知道怎么解决,哪位大神指点一二。
程序代码:
#include<stdio.h> #include<malloc.h> #define OK 1 #define ERROR 0 typedef struct lnode { int data; struct lnode *next; }lnode, *linklist; typedef int status; void creatlist(linklist &l, int n); status listdelete(linklist &l, int i, int &e); int main() { linklist l, p; int n = 10; creatlist(l, n); p = l->next; while (p) { printf("%d ", p->data); p = p->next; } printf("\nPlease input the delete number\n"); int i, e; linklist q; scanf_s("%d", i); listdelete(l, i, e); q = l->next; while (q) { printf("%d", q->data); q= q->next; } printf("The number delete is%d", e); getchar(); getchar(); return 0; } void creatlist(linklist &l, int n) { linklist p; int i; l = (linklist)malloc(sizeof(lnode)); l->next = NULL; for (i = n; i > 0; i--) { p = (linklist)malloc(sizeof(lnode)); scanf_s("%d", &(p->data)); p->next = l->next; l->next = p; } } status listdelete(linklist &l, int i, int &e) { linklist p, q; int j=0; p = l; while (p&&j < i - 1) { p = p->next; j++; } if (!(p->next) || j > i - 1) return ERROR; q = p->next; e = p->data; p->next = q->next; free(q); return OK; }
[此贴子已经被作者于2018-9-24 18:19编辑过]