读取整数文件并将每一行存储在一个单独的数组中

Read integer file and store EACH line in ONE separate array

我正在尝试读取此文件并将每一行存储在一个数组中。有人可以告诉我如何为此实现代码吗?

2
2 10 1 2 7
3 8 3 7 7 10 7

我有下面的代码,我可以将文本文件的每个元素保存到一个数组中,但我需要将行保存到单独的数组中。我该怎么做?

fstream myfile("myfile's_address", ios_base::in);

int a;
while (myfile >> a)
{
    word[increment] = a;
    increment++;
}

首先,使用 ifstream 而不是 fstreamios_base::in

接下来,使用std::getline()将一行作为字符串,为其创建一个向量(可能在vector<vector<string>>中),然后解析它(可能使用std::istringstream)。