GNSS-by flying fish 2018-12-27 11:00 采纳率: 50%
浏览 4898
已采纳

为什么vs提示引发了未经处理的异常:读取访问权限冲突。 **Bt** 是 0xCCCCCCCC。

#include"stdio.h"
typedef struct tree
{
char element;
struct tree leftchild, *rightchild;
}Tree;
Tree
malloc2(void)//为新节点申请动态空间
{
Tree* p;
p = (Tree*)malloc(sizeof(Tree));
/*if (IS_FULL(p))
{
fprintf(stderr, "The memery is full\n");
exit(1);
}*/
return p;
}
void linkchild(Tree Bt, char element, Tree *lchild, Tree *rchild)//给树连接孩子
{
Tree
p = malloc2();//为p申请动态空间
p->leftchild = lchild;
p->rightchild = rchild;
p->element = element;
lchild = rchild = NULL;
Bt = p;
}
void BreakBTree(Tree Bt, char *element, Tree *lchild, Tree *rchild)//释放Bt的空间
{
if (Bt)
{
*element = Bt->element;
lchild = Bt->leftchild;
rchild = Bt->rightchild;
Bt = NULL;
free(Bt);
}
}
void visit(Tree
Bt) //打印节点元素
{
if (Bt)
printf("%c", Bt->element);
}
void Fvisit(Tree *Bt) //先序遍历
{
if (Bt)
{
visit(Bt);
Fvisit(Bt->leftchild);
Fvisit(Bt->rightchild);
}
}
void Mvisit(Tree *Bt) //中序遍历
{
if (Bt)
{
Mvisit(Bt->leftchild);
visit(Bt);
Mvisit(Bt->rightchild);
}
}
void Lvisit(Tree *Bt) //中序遍历
{
if (Bt)
{
Lvisit(Bt->leftchild);
Lvisit(Bt);
Lvisit(Bt->rightchild);
}
}
void main()
{
Tree a, x, y, z;
linkchild(&x, 'E', &a, &a);
linkchild(&y, 'F', &a, &a);
linkchild(&z, 'C', &x, &y);
linkchild(&y, 'D', &a, &a);
linkchild(&x, 'B', &y, &z);
Fvisit(&x);
while (1)
{

}

}

  • 写回答

1条回答 默认 最新

  • threenewbee 2018-12-27 03:58
    关注

    首先,你要知道0xCCCCCCCC是什么东西。
    这是VC++一个非常有用的功能。
    VC++的调试版程序(注意,release版没有),在你调用malloc申请了内存之后,会把这个内存块全部填充成0xCC
    所以,遇到这种提示,想都不用想就知道肯定是分配了内存,没有初始化变量。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?