文件的读与写操作
来源:互联网 发布:大数据集成平台 编辑:程序博客网 时间:2024/04/30 19:56
//文件的读与写操作.cpp
#include <iostream.h>
#include"fstream.h"
#include<stdlib.h>
#define SIZE 2
typedef struct{
char name[10];
int num;
int age;
char addr[15];
}STU;
STU stud[SIZE]={{"zhang",1001,13,"room1"},
{"li",1002,23,"room2"}
};
void main(void)
{
STU temp;
fstream fp("d://f1.txt",ios::out|ios::in|ios::binary);
if(fp.fail()){
cout<<"cannot open file/n";
exit(1);
}
for(int i=0;i<SIZE;i++)
fp.write((char*)&stud[i],sizeof(STU));
fp.seekg(sizeof(STU),ios::beg);//移动读指针,离其始位置sizeof(STU)字节
cout<<fp.tellg()<<endl; //返回当前读指针的位置距流开始位置的字节数
fp.read((char*)&temp,sizeof(STU));
cout<<temp.name<<" "<<temp.num<<" "<<
temp.age<<" "<<temp.addr<<endl;
fp.close();
}
- 文件的读与写操作
- 文件的写操作
- 文件的写与读
- 文件的读与写
- C++编程的“读”与“写”操作
- C++ 文件操作 -- 读与写 基本实现
- MFC里文件的读与写
- Android 文件操作 读/写
- python 读/写文件操作
- C++读、写、文件操作!
- 打开文件和写文件的操作
- 文件的简单操作 : 读、写(覆盖写、追加写)、复制、剪切、新增、删除
- Delphi文件操作-读文件-写文件-操作文件
- CFlie操作-读与写
- 对HDFS文件系统文件的读、写、删操作
- 对HDFS文件系统文件的读、写、删操作
- 对HDFS文件系统文件的读、写、删操作 .
- 简单的对文件操作,如复制,读,写
- 全局变量与局部变量的地址
- TI_DSP链接命令文件(*.cmd)的介绍
- CCS的GEL文件
- Tomcat(8-1) Container Interface
- 文件操作
- 文件的读与写操作
- JCreator
- 文件复制操作
- Ruby的GC机制源码分析(1)
- 现实
- 冒泡排序
- 设计多层线路板设计基础知识
- 链表的建立插入与删除
- 快速排序