回复 12楼 pycansi
问题我还没找到,我用其他方式代替了,我写了一个包含这个错误的很简单的程序,你可以试着找找原因,找到了请告诉我一声,非常感谢。
#include<stdio.h>
#include <ctype.h>
#define MAXLEN 1000
#include <string.h>
#include <stdlib.h>
struct node {
int biaozhi;
char *p;
struct node *zuo;
struct node *you;
};
int shuzhuangfuzhi(struct node *, char *word);
int main()
{
struct node *p = NULL;
int
c = 0,i=0;
char word[MAXLEN];
char *fuzhi[MAXLEN] = {"hello","man",NULL};
while (fuzhi[i]!=NULL)
{
p = shuzhuangfuzhi(p, fuzhi[i++]);
}
system("pause");
}
struct node *talloc(void);
char *strup(char *);
int shuzhuangfuzhi(struct node *p, char *word)
{
int a;
if (p == NULL)
{
p = talloc();
p->biaozhi = 0;
p->p = strup(word);
p->zuo = NULL;
p->you = NULL;
}
else
shuzhuangfuzhi(p->zuo, word);
return p;
}
struct node *talloc(void)
{
return (struct node *) malloc(sizeof(struct node));
}
char *strup(char *s)
{
char *p;
p = (char *)malloc(strlen(s) + 1);
if (p != NULL)
strcpy_s(p, 50, s);
return p;
}