我得到以下错误:
线程1接收信号SIGSEGV,分段错误
代码如下:
int extraercadena(char *cad, char *tCad, int ini, int fin){
int iC, iS;
if ((ini>fin) || (ini < 0) || (fin >= strlen(cad)))
return 0;
iS = 0;
for(iC = ini; iC <= fin; iC++){
//error is here, the system halt here
tCad[iS] = cad[iC];
iS++;
}
tCad[iS] = ' ';
return 1;
}
有七种可能性:
cad
无法取消引用,因为它未初始化或为NULL或是无效指针- CCD_ 2为阴性
- CCD_ 3不指向至少具有CCD_ 4元素的数组
tCad
无法取消引用,因为它未初始化或为NULL或是无效指针- CCD_ 6不指向至少具有CCD_ 7元素的数组
tCad
指向不可写的内存。(例如,字符串文字返回的内存在可能的情况下通常是只读的。(- 这是程序中其他一些未定义行为的结果。(不太可能。(