64,643
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
const int ROW = 10;
const int COL = 16;
int myArray[ROW][COL];
int main()
{
ifstream is("my.txt");
if (!is) {
cout << "Cannot open the file." << endl;
return 0;
}
char str[1024];
int i = 0, j;
while (is.getline(str, 1024) && i < ROW) {
istringstream iss(str);
j = 0;
while (j < COL && iss >> myArray[i][j++]);//Empty
++i;
}
for (i = 0; i < ROW; ++i) {
for (j = 0; j < COL; ++j) {
cout << myArray[i][j] << " ";
}
cout << endl;
}
return 0;
}