user-0 提问: 请大神帮忙指点  编辑没错，运行不出来

回复:
user: user-1
content: 代码功能归根结底不是别人帮自己看或讲解或注释出来的；而是被自己静下心来花足够长的时间和精力亲自动手单步或设断点或对执行到某步获得的中间结果显示或写到日志文件中一步一步分析出来的。 提醒：再牛×的老师也无法代替学生自己领悟和上厕所！ 单步调试和设断点调试（VS IDE中编译连接通过以后，按F10或F11键单步执行，按Shift+F11退出当前函数；在某行按F9设断点后按F5执行停在该断点处。）是程序员必须掌握的技能之一。

user: user-2
content: 1楼是把Sqstack s;改成Sqstack * s; 我这里是把Sqstack s;改成全局变量，楼主你喜欢哪个？ #include＜stdio.h＞ #include ＜malloc.h＞ #include ＜stdlib.h＞ #define STACK_SIZE 100 #define STACK_INCRE 3  typedef int ElemType; //定义栈的存储结构 struct Sqstack { 	ElemType *base; 	ElemType *top; 	int stacksize; };  struct { 	char son[20]; 	char parent[20]; 	long num; 	}related[6] = {  {"system", "mib", 1},  {"mib","", 1},  {"sysdescr", "system",1},  {"sysobjectid", "system", 2},  {"sysuptime", "system",3},  {"interface", "mib", 2}}; //初始化栈s    struct Sqstack s; void InitStack() { 	s.base=(ElemType*)malloc(STACK_SIZE*sizeof(ElemType)) ; 	if(!s.base) 	exit(1); 	s.top=s.base ; 	s.stacksize =STACK_SIZE ; 	printf("栈s已被初始化:\n"); 	} //向栈s的第i个位置压入元素e    void Push(ElemType e) { 	if(s.top-s.base==STACK_SIZE) 	{ 		  s.base=(ElemType*)realloc(s.base,(s.stacksize +STACK_INCRE)*sizeof(ElemType));    		   s.top=s.base+s.stacksize; 		      s.stacksize+=STACK_INCRE;      }     *(s.top)=e; 	s.top++;  }    		//输出栈s的栈顶元素，并赋值给变量e int Pop(ElemType &e) { 	if(s.top==s.base)    	return 0; 	--s.top; 	e=*s.top; 	return 1; }     int main() { 	int flag,j,i; 	char str[20]; 	ElemType e; 	InitStack(); 	printf("\n"); 	printf("输出查询元素："); 	gets(str); 	while (strlen(str)!=0) 	   for (i=0; i＜6; i++) 	   { 	  	if(!strcmp(str,related[i].son)) 	  	{ 	  		strcpy(str,related[i].parent);  	  		 Push(related[i].num); 	  	} 	  } 	  printf("输出栈中元素：\n"); 	  flag=Pop(e);   	while(flag!=0) 	  { 	  	printf("%d",e); 	  	flag=Pop(e); 	  	printf("\n"); 	  } }

user: user-3
content: #include<stdio.h> #include<string.h> #include <malloc.h> #include <stdlib.h>  typedef int ElemType;  #define STACK_SIZE 100 #define STACK_INCRE 3  //定义栈的存储结构 typedef struct { ElemType *base; ElemType *top; int stacksize; } Sqstack; struct {   char son[20];   char parent[20];   long num; }related[6] = {   {"system", "mib", 1},   {"mib",{0}, 1},   {"sysdescr", "system",1},   {"sysobjectid", "system", 2},   {"sysuptime", "system",3},   {"interface", "mib", 2}, };  //初始化栈s void InitStack( Sqstack *s ) {     s->base =   ( ElemType * )malloc(   STACK_SIZE * sizeof( ElemType ) ) ;     if( !s->base )     exit(1);     s->top = s->base;     s->stacksize = STACK_SIZE ;     printf( "栈s已被初始化:\n" ); }  //向栈s的第i个位置压入元素e void Push( Sqstack *s, ElemType e ) {      if( s->top - s->base == s->stacksize ){         s->base = ( ElemType * )realloc( s->base, ( s->stacksize + STACK_INCRE ) * sizeof( ElemType ) );         s->top = s->base + s->stacksize;         s->stacksize += STACK_INCRE;     }     *( s->top ) = e;     s->top++; }  //输出栈s的栈顶元素，并赋值给变量e int Pop( Sqstack *s, ElemType *e ) {     if( s->top == s->base )     return 0;     --s->top;     *e = *s->top;     return 1; }    int main( void ) {     int flag;     char str[20];     Sqstack *s;     s = ( Sqstack * )malloc( sizeof( Sqstack ) );     ElemType e;     InitStack( s );     printf( "\n" );     printf( "输入查询元素：" );     gets( str );     while( strlen( str ) != 0 )         for( int i = 0; i < 6; i++ ){             if( !strcmp( str, related[i].son ) ){                 strcpy( str, related[i].parent );                 Push( s, related[i].num );             }         }     printf( "输出栈中元素：\n" );     flag = Pop( s, &e );     while( flag != 0 ){         printf( "%d", e );         flag = Pop( s, &e );         printf( "\n" );     } } 按照你的代码改的 但输出结果不知道是不是和你的意思一样