我寫了一段代碼。這看起來如下。分段故障運行時錯誤
#include<stdio.h>
#include<string.h>
int do_print2(char *q[]);
int main()
{
char *p[]={"pointervaule","NAM", "JAM", "CALM"};
do_print2(p);
return 1;
}
int do_print2(char *p[])
{
printf("this is print1 char *p \n");
strcat(p[0],"added");
printf("%s\n", (p[0]));
return 1;
}
編譯後,我試圖運行它,我得到分段錯誤。幫助我瞭解那個錯誤的原因是什麼。預先感謝。
HII Grijesh肖漢,首先非常感謝全幫我修復這個錯誤,和U可以讓我知道一本書或者一些讓我在處理指針和字符串時感覺舒適的物質。 (任何教程?) –
@SrinivasThanneeru一個巨大的列表:[The Definitive C Book Guide and List](http://stackoverflow.com/questions/562303/the-definitive-c-book-guide-and-list)以及for [指針](http://stackoverflow.com/questions/tagged/pointers) –
@SrinivasThanneeru如果需要用C編寫代碼,他/她應定期閱讀[FAQ](http://c-faq.com/) –