[Ubuntu-zh] gdb下的调试问题

Gmail - leon360e leon360e在gmail.com
星期二 二月 28 13:24:36 UTC 2012


  for(p;p<c+3;p++)
定义的**p,中p++偏移量是1,
按照你的想法,应该是p += 3才行。


于 2012年02月28日 21:07, Endwens Cheng 写道:
>   1       #include<stdio.h>
> 2       #include<stdlib.h>
> 3       int main ()
> 4       {
> 5               char *c[3];
> 6               char **p;
> 7               int i=0;
> 8               p=c;
> 9               printf("please enter the strings: ");
> 10              for(p;p<c+3;p++)
> (gdb)
> 11                      scanf("%s",*p);
> 12              p=c;
> 13              for(p;p<c+3;p++)
> 14                      printf("%s",*p);
> 15              exit(0);
> 16      }
> 输入并输出3个不等长字符串,gdb调试出现段错误,backtrace后应该是代码的11行出了问题,不知是什么原因,求解答
> -------------- 下一部分 --------------
> 一个HTML附件被移除...
> URL:<https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20120228/5d5949ce/attachment.html>



关于邮件列表 ubuntu-zh 的更多信息