打印函数调用堆栈 故意制造错误

打印函数调用堆栈 故意制造错误 
给空指针赋值:
int *p;
*p=2;

堆栈错误???

01-22

//adt.hrnrn#define stack_init_size 100;rn#define stack_increment 10;rnrntypedef structrnrn char *base;rn char *top;rn int stacksize;rnsqstack;rnrn//stack.cpprn#includern#include"ADT.H"rnrnint initstack(sqstack &s)rnrn s.base=(char*)malloc(stack_init_size*sizeof(char));rn if(!s.base) return 0;rn s.top=s.base;rn s.stacksize=stack_init_size;rn return 1;rnrnrnint gettop(sqstack s,char &e)rnrn if(s.top==s.base)rn return 0;rn elsern e=*(s.top-1);rn return 1;rnrnrnint push(sqstack &s,char e)rnrn if(s.top-s.base>=s.stacksize)rn rn s.base=(char*)realloc(s.base,(s.stacksize+stack_increment)*sizeof(char));rn rn if(!s.base)rn return 0;rn s.top=s.base+s.stacksize;rn s.stacksize+=stack_increment;rn rn *s.top++=e;rn return 1;rnrnrnint pop(sqstack &s,char &e)rnrn if(s.top==s.base)rn return 0;rn e=*--s.top;rn return 1;rnrnrnint stackempty(sqstack s)rnrn if(s.top==s.base)rn return 1;rn elsern return 0;rnrn//main.cpprn#includern#include"ADT.H"rnextern int initstack(sqstack &s);rnextern int gettop(sqstack s,char &e);rnextern int push(sqstack &s,char e);rnextern int pop(sqstack &s,char &e);rnextern int stackempty(sqstack s);rnusing namespace std;rnint main()rnrn char e;rn sqstack s;rn initstack(s);rn int n,m;rn cin>>n;rn cin>>m;rn while(n)rn rn int k=0;rn if(n%m>=10)rn k=(n%m-10)+97;rn elsern k=n%m+48;rn push(s,char(k));rn n=n/m;rn rn while(!stackempty(s))rn rn pop(s,e);rn printf("%c",e);rn rn return 0;rnrn写的是关于进制转换的代码rn调试后rnstack.cpp(6) : error C2143: syntax error : missing ')' before ';'rnstack.cpp(6) : error C2059: syntax error : ')'rnstack.cpp(6) : error C2100: illegal indirectionrnstack.cpp(26) : error C2143: syntax error : missing ')' before ';'rnstack.cpp(26) : error C2143: syntax error : missing ')' before ';'rnstack.cpp(26) : error C2059: syntax error : ')'rnstack.cpp(26) : error C2059: syntax error : ')'rnstack.cpp(26) : error C2100: illegal indirection

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试