#include <fstream>
#include <vector>
#include <Eigen/Dense>
#include <iostream>
int main()
{
std::vector<Eigen::Vector3d> world_points;
{
std::string file("/home/qiang/pointPairs/3D_01_1.txt");
std::ifstream infile(file);
while(true) // 最常见的错误读取方式为: while(!infile.eof()) {...;}
{
double x, y, z;
infile >> x >> y >> z;
if(infile.eof())
{
break;
}
Eigen::Vector3d vec(x, y, z);
world_points.push_back(vec);
}
infile.close();
}
std::cout << "valid lines: " << world_points.size() << "n";
for (auto &p : world_points)
{
std::cout << p.transpose() << "n";
}
return 0;
}
最后
以上就是糟糕面包最近收集整理的关于使用ifstream避免重复读取txt文件最后一行的正确读取方法的全部内容,更多相关使用ifstream避免重复读取txt文件最后一行内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复