正如我的标题所指定的,我需要读取文本文件(C++)中的信息。 我看到很多例子涉及有组织数字或字符串列表的文本文件,但对我来说,我需要安排如下文件(example.txt文件)中提取信息:阅读文本文件中的特定信息
// This is the begin of the text file:
Here_the_coordinates_are_going_to_be_listed
Start
x y z
0 0 0
1 0 0
1 1 0
0 1 0
End
而且我会非常读并将其存储在“的std ::载体”,载“开始”之间的信息“结束”,使得矩阵A N×3矢量:
matrix[i][j] = 0 0 0
1 0 0
1 1 0
0 1 0
我给看看教程和我的一切到目前为止是:
std::array<std::array<int , 5>, 7> matrix;
std::ifstream file("../test/matrix.txt");
for (unsigned int i = 0; i < 7; i++)
{
for (unsigned int j = 0; j < 5; j++) {
file >> matrix[i][j];
}
它允许我读取只写入数字的文件。
非常感谢你,
达里奥
这是你所有的代码? – 2014-08-31 19:48:23
不,我能够读取和存储矩阵,如果文件很简单,但在这种情况下,我不知道如何填充文本文件第5行的矩阵。 – dario 2014-08-31 20:15:08