随笔分类 -  文件流

摘要:上次只是第一次学习了下C++如何操作文件流。今天深入了解了,写下自己的心得。今天主要是打开文件,以前只是简单的输入,今天练习了输入一大堆内容。首先还是#include<iostream>#include<fstream>using namespace std;int main(){ const int buffer=500;//可以输入文件大小 char temp1[buffer]={'\0'};//定义输入文件的副本 chae temp2[buffer]={'\0'};定义输出文件的副本ofstream write("test 阅读全文
posted @ 2012-02-21 20:55 RINA
摘要:文件流里面:fstream表示文件流,ifstream和ofstream是两种文件流方式:输入和输出ifstream从磁盘文件输入到缓存中,最后到显示屏上,即读数据。ofstream将数据写入到磁盘文件,即写数据,下面这个例子很好的体现了这个方法: #include<iostream>#include<fstream>#include<iomanip>#include<string>using namespace std;int main(){ ofstream file1("D:\\1234.txt",ios::app);/ 阅读全文
posted @ 2012-02-07 00:26 RINA