看板 C_and_CPP 關於我們 聯絡資訊
char pA[]="Content-type: text/html\n\nThis is a pen"; 如果我把pA[]改成*pA,編譯就會出現Segmentation fault 為什麼不能寫*pA? 這樣就沒辦法跟strstr一起用了欸=.= char *p; char *delim="/\n"; strtok(pA, delim); p = strtok(NULL, delim); printf("%s", p); 感謝解惑~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.251.183.145 ※ 編輯: apiod 來自: 60.251.183.145 (05/03 14:32)
james732:置底文十二誡第四 05/03 14:49
freesamael:我補充說明一下,strtok會去修改來源字串, 05/03 15:28
freesamael:而常數字串無法被修改,所以就爛掉了。 05/03 15:28
apiod:thanks 05/03 16:04