求解答:C语言编程出现问题,编译无错,但无法运行

2025-04-07 10:59:04
推荐回答(1个)
回答1:

#include 
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;
}
//还有就是主函数如何调用的?

恕我直言,你这代码都是错误的,如果有需求可以把完整代码贴出来.