C读取文件,这种写法不会多一行。

 #include "stdafx.h"
#include <vector>
using namespace std;
struct PointXYZ
{
double X;
double Y;
double Z;
}; int _tmain(int argc, _TCHAR* argv[])
{
FILE* in=fopen("D:\\project60-cut-1000.txt","r");
if(in==NULL)
{
printf("missing file");
return ;
}
double tmp=;
//char buff[255] = {};
float x;
float y;
float z;
vector<PointXYZ> *points=new vector<PointXYZ>();
char* str;
int i=;
// while(!feof(in))
fscanf(in,"%f %f %f",&x,&y,&z);
while(feof(in)==) /*判断是否文件尾,不是则循环*/
{
i++;
PointXYZ point;
point.X=x;
point.Y=y;
point.Z=z;
points->push_back(point);
fscanf(in,"%f %f %f",&x,&y,&z);
}
fclose(in); for (vector<PointXYZ>::iterator iter = points->begin(); iter != points->end(); ++iter)
{
PointXYZ tmp=(PointXYZ)*iter;
printf("%f %f %f\n",tmp.X,tmp.Y,tmp.Z);
}
printf("Number:%d\n",(int)points->size());
 system("pause");//getchar();
return ;
}

参考C++的读取

 void LoadImages(const string &strAssociationFilename, vector<string> &vstrImageFilenamesRGB,
vector<string> &vstrImageFilenamesD, vector<double> &vTimestamps)
{
ifstream fAssociation;
fAssociation.open(strAssociationFilename.c_str());
while(!fAssociation.eof())
{
string s;
getline(fAssociation,s);
if(!s.empty())
{
stringstream ss;
ss << s;
double t;
string sRGB, sD;
ss >> t;
vTimestamps.push_back(t);
ss >> sRGB;
vstrImageFilenamesRGB.push_back(sRGB);
ss >> t;
ss >> sD;
vstrImageFilenamesD.push_back(sD); }
}
}

最新文章

  1. 倒计时的js实现 倒计时 js Jquery
  2. 使用OFBIZ 时,使用的键入提示。
  3. bootstrap学习笔记之二
  4. vim 学习记录2
  5. IOS中控制器的重要方法使用
  6. *MySQL卸载之后无法重装,卡在Apply security settings:Error Nr.1045
  7. Eclipse常用插件推荐
  8. Spring (二) OOP V.S AOP
  9. 慢查询日志分析(mysql)
  10. 一个ExtJS实例
  11. 【Qt编程】基于Qt的词典开发系列&lt;十二&gt;调用讲述人
  12. Android版数据结构与算法(一):基础简介
  13. 蓝桥杯刷题,第四界省赛B组
  14. C# 使用密码连接Redis
  15. 带你领略Linux系统发展及版本更迭
  16. 一个前端开发者换电脑的过程(git篇)
  17. mybatis-generator插件执行报错:Cannot resolve classpath entry
  18. linux学习之uniq
  19. Certificate Formats | Converting Certificates between different Formats
  20. SharePoint Framework 企业向导(一)

热门文章

  1. 配置Log4j(很详细)
  2. js性能优化的小知识
  3. jpush极光推送知识点总结
  4. python实现查找指定文件
  5. WordPress博客教程:博客赚钱
  6. 数据库MySql阶段总结
  7. von Neumann architecture
  8. RSA
  9. 汇总10.4版本ArcGIS Server与ArcMap 安装+SDE+注册数据源(非破解)
  10. Lazarus IDE的几个小技术