#include <stdio.h>
#include <stdlib.h>
int main(){
char *str="abcdce";
char c='c';
char *pfast=str,*pslow=str;
while(*pfast!='\0'){
if(*pfast==c){
pfast++;
*pslow=*pfast; //error here when pfast reaches the first 'c'
}
pfast++;
pslow++;
}
*pslow='\0';
return 0;
}
當它運行到的賦值語句段故障「* pslow = * pfast;」 ......字符指針賦值段故障
有人告訴我爲什麼,在此先感謝!
您是不是要找™'pslow = pfast;'? – 2011-03-26 13:07:31