你并没有分配空间啊,scanf当然会出错
在 2012年2月28日 下午9:07,Endwens Cheng <[email protected]>写道:
> 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 mailing list
> [email protected]
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh
>
-------------- 下一部分 --------------
一个HTML附件被移除...
URL:
<https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20120228/1577ff55/attachment.html>
--
ubuntu-zh mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh