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 优质github账号直接兑换rmb,感兴趣伙伴可以私信
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)