看板 C_and_CPP 關於我們 聯絡資訊
想要讀入一個檔案如下 n tt and Ar ar . . . 想要把每行讀入一個指標陣列 又不想用gerline 目前的想法是 int main() { int i; char *number=new char[1000]; ifstream instream; instream.open("test.txt") for(i=0;i<5;i++) instream>>number; cout<<number[1]; instream.close(); } 本來以為輸出會是tt 結果是t 對指標陣列還不太熟 懇請版友解惑 感謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 134.208.33.70 ※ 編輯: cophie 來自: 134.208.33.70 (03/15 20:15)
legnaleurc:why not std::string ? 03/15 20:17
legnaleurc:你要的結果應是 cout << number; 03/15 20:18
cophie:感謝樓上 03/15 20:56
jasonfghx:GJ 12/28 23:26