struct people
{
char * name;
int ages;
};
people * * person;
那么*person表示的是否是结构体的地址呢?person又是表示什么意思呢?
{
char * name;
int ages;
};
people * * person;
那么*person表示的是否是结构体的地址呢?person又是表示什么意思呢?
解决方案 »
- 急!!!!!!!!请问在主对话框里添加一个按钮,点击按钮弹出一个子对话框,如何让子对话框里的静态控件的字体是透明的?????
- 如何获取3G信号强度、统计3G数据上下行流量?
- 关于BCG界面库的问题
- GetFirstDocTemplatePosition
- 如何关闭通过webbrowser控件打开的doc文档?
- 有这么一个问题:基于FormView创建单文档,然后创建对话框资源,把对话框作为子对话框显示在单文档界面中,对话框中的控件可以显示出来。
- Delete指针时出错?
- 用VC调试C源程序的时候进不了函数
- 简单的编程问题?请教,谢谢!
- CALLBACK怎么用
- 几个问题,大家都来看看,帮个忙!
- 怎样读取硬盘的序列号?
person 是一个指向这个地址的指针
people *person 表示一个结构体指针
people * * person 表示一个结构体指针的指针
struct stack
{
people **top; //**top or *top;
people **bottom;//是*bottom还是**bottom;
}
{
char data;
BiTree * lchild, *rchild;
};
struct stack
{
//BiTree var;
BiTree * *top, * *bottom;
};
bool stackinit(stack s)
{
s.top=s.bottom=(BiTree * *)malloc(sizeof(BiTree *)*100);
if(!s.top)
return 0;
return 1;
}
void push(stack s,BiTree * e)
{
* *(s.top)=*e;//运行到这里提示s.top没有初始化。可是在stackinit中不是已经初始化了吗?而且我是先运行stackinit(s)的呀!
(s.top)++;
}
我在stackinit(s)里面加了
*(s.top)=*(s.bottom)=(BiTree *)malloc(sizeof(BiTree *)*100);
但是没有用!!!
void push(stack s,BiTree * e)
{
* (s.top)=e;
*(s.top)++;
}
#include <stdlib.h>struct BiTree
{
char data;
BiTree * lchild, *rchild;
};
struct stack
{
//BiTree var;
BiTree * *top, * *bottom;
};
bool stackinit(stack *s)
{
s->top=s->bottom=(BiTree * *)malloc(sizeof(BiTree * *)*100); if(!s->top)
return 0;
return 1;
}
void push(stack *s,BiTree * e)
{
*(s->top)=*(s->bottom)=(BiTree *)malloc(sizeof(BiTree *));
*(*(s->top))=*e;
(s->top)++;
}
struct BiTree * pop(stack *s)
{
return (*(s->top))--;
}
bool stackempty(stack *s)
{
if(s->top==s->bottom) return 1;
return 0;
}bool visit(int Node)
{
printf("%d",Node);
return 1;
}bool VisitBiTree(struct BiTree * p)
{
// BiTree *p=T;
stack *s=(stack*)malloc(sizeof(stack));
stackinit(s);
push(s,p);
while(p||!stackempty(s))
{
while(p)
{
visit(p->data);
push(s,p);
p=p->lchild;
}
if(!stackempty(s))
{
p=pop(s);
p=p->rchild;);//在这里,死了。
}
}
return 1;
}
{
visit(p->data);
push(s,p); //你保存的是指针.
p=p->lchild; //这里你又修改了指针.S里的最后一个数据实际是最左叶结点(没有L,可能有R)
}
//这里执行过后.P指向最左的叶结点.它的L为NULL.R未知.if(!stackempty(s))
{
p=pop(s); //得到最左叶结点.不知道有没有R?
p=p->rchild;);//如果没有R,死了。
}
{
s->top=s->bottom=(BiTree * *)malloc(sizeof(BiTree *)*100); if(!s->top)
return 0;
return 1;
}
void push(stack *s,BiTree * e)
{
*(s->top)=e;
(s->top)++;
}/*
*(s->top)=*(s->bottom)=(BiTree *)malloc(sizeof(BiTree *));
这是干什么?你在堆栈里到底乡村什么?是数据还是地址?先能清楚!
*/
#include <stdlib.h>struct BiTree
{
char data;
BiTree * lchild, *rchild;
};
struct stack
{
//BiTree var;
BiTree * *top, * *bottom;
};
bool stackinit(stack *s)
{
s->top=s->bottom=(BiTree * *)malloc(sizeof(BiTree * *)*100); if(!s->top)
return 0;
return 1;
}
void push(stack *s,BiTree e)
{
*(s->top)=*(s->bottom)=(BiTree *)malloc(sizeof(BiTree *));
*(*(s->top))=e;
(s->top)++;
}
struct BiTree pop(stack *s)
{ return *(*(s->top))--;
}
bool stackempty(stack *s)
{
if(s->top==s->bottom) return 1;
return 0;
}bool visit(int Node)
{
printf("%d",Node);
return 1;
}bool VisitBiTree(struct BiTree * p)
{
// BiTree *p=T;
stack *s=(stack*)malloc(sizeof(stack));
stackinit(s);
push(s,*p);
while(*p||!stackempty(s))
{
while(*p)//结构体是不能这样判断的!!!
{
visit((*p).data);
push(s,p);
*p=(*p).lchild;
}
if(!stackempty(s))
{
*p=pop(s);
*p=(*p).rchild;
}
}
return 1;
} int main(int argc,char * argv[])
{
struct BiTree * T=(BiTree *)malloc(sizeof(BiTree));
T->data=1;
T->lchild=(BiTree *)malloc(sizeof(BiTree));
T->lchild->data=2;
T->lchild->lchild=NULL;
T->lchild->rchild=NULL;
T->rchild =(BiTree *)malloc(sizeof(BiTree));
T->rchild->data=3;
T->rchild->lchild=NULL;
T->rchild->rchild=NULL; VisitBiTree(T);
return 0;
}
到底应该怎么修改???
{
BiTree *pNode=p; //表示当前指针
stack *s=(stack*)malloc(sizeof(stack));
stackinit(s);
push(s,p);
while(p||!stackempty(s))
{
while(p)
{
visit(p->data);
push(s,p);
pNode=p->lchild;
}
if(!stackempty(s))
{
pNode=pop(s);
p=pNode->rchild;);
}
}
return 1;
}
{
*(s->top)=*(s->bottom)=(BiTree *)malloc(sizeof(BiTree *));
*(*(s->top))=e;
(s->top)++;
}如果你想在堆栈中存数据:
void push(stack *s,BiTree *e)
{
BiTree *pstNew;
pstNew = (BiTree*)malloc(sizeof(BiTree));
if ( !pstNew )
return;
*pstNew = *e;
*(s->top)=pstNew;
(s->top)++;
}
如果你想在堆栈中存数据address:
void push(stack *s,BiTree *e)
{
*(s->top)=e;
(s->top)++;
}
this program not decide the limit of 100 , and other,so it didn't finish,and don't know top should ++ or bottom ++, and 由于你没有保存你动态分配的首地址,所以思路就是错的。s->top=s->bottom=(BiTree * *)malloc(sizeof(BiTree * *)*100);top and bottom 总是在变,所以内存比丢。