请问编译后执行时会出现Aborted

我在linux下用gcc编译一程序,
执行时总是在最后出现Aborted字样
请问各位大侠这是怎么会事
源代码如下:
#include

 1<stdio.h>   
 2void copy_string(char *from, char *to)   
 3{   
 4while ((*to++ = *from++)!='\0');   
 5}   
 6main()   
 7{   
 8char *a = "hello";   
 9char *b;   
10copy_string (a,b);   
11printf("a is %s\n",a);   
12printf("b is %s\n",b);   
13}   
14  
15\---------------------------------------------------------------   
16  
17hehe,there's no space for b   
18\---------------------------------------------------------------   
19  
20b还没有分配内存.   
21  
22main()   
23{   
24char *a = "hello";   
25char *b;   
26b = new char; //新增   
27copy_string (a,b);   
28printf("a is %s\n",a);   
29printf("b is %s\n",b);   
30}</stdio.h>
Published At
Categories with 服务器类
Tagged with
comments powered by Disqus