0
Adam Peter Eric
John Edward
Wendy
我想在3串陣列(每行表示一個數組)來存儲,但我被困關於如何逐行讀取它。
這裏是我的代碼:
string name [3][3] ;
ifstream file ("TTT.txt");
for (int x = 0; x < 3; x++){
for (int i = 0; x < 3; i++){
while (!file.eof()){
file >> name[x][i];
}
}
}
cout << name[0][0];
cout << name[0][1];
cout << name[0][2];
cout << name[1][0];
cout << name[1][1];
cout << name[2][0];
}
你有行1文件,並在第3行 – LeppyR64 2014-08-30 22:58:06
INFILE沒有看到,糾正它。謝謝 – 2014-08-30 22:59:17
我想將它存儲在二維數組中,並且位置確實很重要。 Adam應該是名字[0] [0],John = name [1] [0] wendy = name [2] [0] – Vanishadow 2014-08-30 23:26:41