这篇主要记录一下使用C++中的动态二维数组来存储读入的txt文档中的数据
//设txt中的数据有rows行和cols列
//使用new新建一个rows行,cols列的二维数组
fstream fin
for (int i = 0; i < cols; i++)
{
array[i] = new int[4];
}
//使用for循环存储读入的每个值
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
fin >> array[i][j];
}
}
#include <fstream>
本篇完。