是字符串按照如下方法定义:1. char * str = "Hello China"; 2. char str = "Hello China";
code1: int main(int argc, char *argv[]) { char *str1 ="Hello"; char *str2 = "China";
printf("%s \n", strcat(str1, str2));
return 0; } 执行结果: Segmentation fault (core dumped)
code2: int main(int argc, char *argv[]) { char str1[] ="Hello"; char str2[] = "China";
printf("%s \n", strcat(str1, str2));
return 0; } 执行结果:HelloChina
求分析! |