|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
# include <stdio.h>
# include <malloc.h>
struct BTNode
{
char data;
struct BTNode * pLchild; //左指针
struct BTNode * pRchild; //右指针
};
void PreTraverseBTree(struct BTNode * );
struct BTNode * CreateBTree(void);
int mian(void)
{
struct BTNode * pT = CreateBTree();
PreTraverseBTree(pT);
return 0;
}
void PreTraverseBTree(struct BTNode * pT)
{
if (NULL != pT)
{
printf(" %c\n", pT->data);
if (NULL != pT->pLchild)
{
PreTraverseBTree(pT->pLchild);
}
if (NULL != pT->pRchild)
{
PreTraverseBTree(pT->pRchild);
}
}
return;
}
struct BTNode * CreateBTree(void)
{
struct BTNode *pA = (struct BTNode *)malloc(sizeof(struct BTNode));
struct BTNode *pB = (struct BTNode *)malloc(sizeof(struct BTNode));
struct BTNode *pC = (struct BTNode *)malloc(sizeof(struct BTNode));
struct BTNode *pD = (struct BTNode *)malloc(sizeof(struct BTNode));
struct BTNode *pE = (struct BTNode *)malloc(sizeof(struct BTNode));
pA->data = 'A';
pB->data = 'B';
pC->data = 'C';
pD->data = 'D';
pE->data = 'E';
pA->pLchild = pB;
pA->pRchild = pC;
pB->pLchild = pB->pRchild = NULL;
pC->pLchild = pD;
pC->pRchild = NULL;
pD->pLchild = NULL;
pD->pRchild = pE;
pE->pLchild = pE->pRchild = NULL;
return pA;
}
编译时没有报错,运行时报错 怎么搞啊?
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/lianbiao2.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
lianbiao2.exe - 1 error(s), 0 warning(s)
入口函数名写错了
int mian(void)
不是 mian() 而是 main()
int main(void)
|
|