C读取文件
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); }
}
}
C读取文件的更多相关文章
- Java 创建文件夹和文件,字符串写入文件,读取文件
两个函数如下: TextToFile(..)函数:将字符串写入给定文本文件: createDir(..)函数:创建一个文件夹,有判别是否存在的功能. public void TextToFile(fi ...
- C#读取文件为byte[]
C#读取文件为byte[] 转载请注明出处 http://www.cnblogs.com/Huerye/ /// <summary> /// 读取程序生成byte /// </sum ...
- HTML5的File API读取文件信息
html结构: <div id="fileImage"></div> <input type="file" value=" ...
- 关于一些对map和整行读取文件操作
public static void main(String[] args) { Map<String, String> map = new HashMap<String, Stri ...
- 使用java读取文件夹中文件的行数
使用java统计某文件夹下所有文件的行数 经理突然交代一个任务:要求统计某个文件夹下所有文件的行数.在网上查了一个多小时没有解决.后来心里不爽就决定自己写一个java类用来统计文件的行数,于是花了两个 ...
- Matlab 读取文件夹中所有的bmp文件
将srcimg文件下的bmp文件转为jpg图像,存放在dstimg文件夹下 str = 'srcimg'; dst = 'dstimg'; file=dir([str,'\*.bmp']); :len ...
- JavaWeb中读取文件资源的路径问题
在做javaweb开发的时候,我们可能会需要从本地硬盘上读取某一个文件资源,或者修改某一个文件,这个时候就需要先找到这个文件,然后用FileInputStrem等文件字节.字符流来将这个文件读取到内存 ...
- File API 读取文件小结
简单地说,File API只规定怎样从硬盘上提取文件,然后交给在网页中运行的JavaScript代码. 与以往文件上传不一样,File API不是为了向服务器提交文件设计的. 关于File API不能 ...
- php函数fgets读取文件
如果一个文件比较大,可以考虑用fgets函数 下面是个例子: #文件作用:fgets读取文件 $start_time = microtime(true); $file_name = "a.t ...
- python用二进制读取文件
python二进制读取文件 很多时候,都需要用到二进制读取文件.毕竟很多信息不是以文本的形式存储.例如:图片,音乐等等.这些东西都是有规则的二进制文件. 在python中,二进制读取采用rb的方式. ...
随机推荐
- 简单实现Redis缓存中的排序功能
1.在实现缓存排序功能之前,必须先明白这一功能的合理性.不妨思考一下,既然可以在数据库中排序,为什么还要把排序功能放在缓存中实现呢?这里简单总结了两个原因:首先,排序会增加数据库的负载,难以支撑高并发 ...
- DirectX基础学习系列1
1.3 基础 1.3.1表面 表面接口: IDirect3DSurface9 获得表面信息:GetDesc(D3DSURFACE_DESC) 获得表面接口指针 :LockRect( D3DLO ...
- wordpress为dashboard添加样式
function my_admin_theme_style() { wp_enqueue_style('my-admin-style', get_template_directory_uri() . ...
- Bootstrap页面布局11 - BS表单
表单之 文本框 text <input type='text' value='' placeholder='输入您的用户名' class='input-mini' /> ①几个类控制文本框 ...
- 6.PHP内核探索:Zend引擎
相信很多人都听说过 Zend Engine 这个名词,也有很多人知道 Zend Engine 就是 PHP 语言的核心,但若要问一句:Zend Engine 到底存在于何处?或者说,Zend Engi ...
- sentinel
Computer Science An Overview _J. Glenn Brookshear _11th Edition Inherent in processing a sequential ...
- Kafka 0.8 配置参数解析
http://kafka.apache.org/documentation.html#configuration Broker Configs 4个必填参数, broker.id Each bro ...
- C# 如何读取一行中的所有变量
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- java Semaphore
//Listing 6-4. Using a Counting Semaphore to Control Access to a Pool of Items import java.util.conc ...
- React.js model
// tutorial1.js var CommentBox = React.createClass({ render: function() { return ( <div className ...