尋找使用scanf函數讀,但我想停止閱讀,如果我遇到一個「」‘\ 0’(行)或EOF拆分scanf函數輸入數組,直到EOF
我真的不知道如何停止實現這一點。
我用
char * aBuff;
char * bBuff;
char * cBuff;
//read in the first three lines and put them into char arrays
//while (scan() != (',' || '\0' || EOF)) //was trying to put it into a while loop, wasn't sure
scanf("%s", aBuff);
scanf("%s", bBuff);
scanf(%s, cBUff);
我打算取輸入,並把它們放在不同的陣列。基本上需要輸入,直到一個或新的行,並將數據放入數組中,並繼續此過程直到文件結束。
'的scanf()'將只能看到格式到''\ 0''。 '「%[^,\ 0]」將顯示爲「」%[^,「'。 – chux 2014-12-04 03:58:17