看板 C_and_CPP 關於我們 聯絡資訊
最近在看分解字串的功能時, 看到用來存每段字串都是用二維陣列去存的 想問一下,以下例子有可以改寫的地方嗎? 一定要用二維的方式去儲存嗎? 謝謝 int i = 0; char *tokenPtr; char *delim = "@"; char p[6][30]; char filename[50] = "@PID@VID@VER@OS@Audio"; tokenPtr = strtok(filename, delim); while(tokenPtr != NULL) { strcpy(p[i], tokenPtr); printf("p[%d] = %s\n", i, p[i]); i++; tokenPtr = strtok(NULL, delim); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.219.143