求解答:C语言编程出现问题,编译无错,但无法运行 5
structline*creatone1(){structline*head,*p;p=(structline*)malloc(sizeof(structline));h...
struct line *creatone1()
{
struct line *head,*p;
p=(struct line*)malloc(sizeof(struct line));
head=(struct line*)malloc(sizeof(struct line));
do
{
if(i==0)
p->col=(struct column*)malloc(sizeof(struct column));
else
{
p->col->next=(struct column*)malloc(sizeof(struct column));
p->col=p->col->next;
}
printf("please input:\n");
scanf("%c",&p->col->ch);
printf("%c",p->col->ch);
i++;
}while(i<20);
return p;
}
struct line *creat1()
{
int a=0;
struct line *head,*p;
for(n=0;n<20;n++)
{
p=creatone1();
a++;
if(a==1)
head=p;
else
head->next1=p;
}
return head;
}
异常代码: c0000005
异常偏移: 000010d8
struct column
{
char ch;
struct column *last;
struct column *next;
};
struct line
{
struct column *col;
struct line *next1;
}; 展开
{
struct line *head,*p;
p=(struct line*)malloc(sizeof(struct line));
head=(struct line*)malloc(sizeof(struct line));
do
{
if(i==0)
p->col=(struct column*)malloc(sizeof(struct column));
else
{
p->col->next=(struct column*)malloc(sizeof(struct column));
p->col=p->col->next;
}
printf("please input:\n");
scanf("%c",&p->col->ch);
printf("%c",p->col->ch);
i++;
}while(i<20);
return p;
}
struct line *creat1()
{
int a=0;
struct line *head,*p;
for(n=0;n<20;n++)
{
p=creatone1();
a++;
if(a==1)
head=p;
else
head->next1=p;
}
return head;
}
异常代码: c0000005
异常偏移: 000010d8
struct column
{
char ch;
struct column *last;
struct column *next;
};
struct line
{
struct column *col;
struct line *next1;
}; 展开
1个回答
展开全部
#include <iostream>
using namespace std;
struct column
{
char ch;
struct column *last;
struct column *next;
};
struct line
{
struct column *col;
struct line *next1;
};
struct line *creatone1()
{
struct line *head, *p;
p = (struct line*)malloc(sizeof(struct line));
head = (struct line*)malloc(sizeof(struct line));
do
{
if (i == 0) //哪里声明的i?
p->col = (struct column*)malloc(sizeof(struct column));
else
{
p->col->next = (struct column*)malloc(sizeof(struct column));
p->col = p->col->next;
}
printf("please input:\n");
scanf("%c", &p->col->ch);
printf("%c", p->col->ch);
i++;
} while (i<20);
return p;
}
struct line *creat1()
{
int a = 0;
struct line *head, *p;
for (n = 0; n<20; n++) //哪里声明的n?
{
p = creatone1();
a++;
if (a == 1)
head = p;
else
head->next1 = p;
}
return head;
}
//还有就是主函数如何调用的?
恕我直言,你这代码都是错误的,如果有需求可以把完整代码贴出来.
追问
int n,i;(全局变量)
int main(void)
{
struct line *head;
for(n=0;n<2n++)
creatone1();}
多谢了
追答
776435029 把你的工程代码给我,不然我也不是很好调试.你是vc写的,我可能要使用vs调试
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询