简单文件输入/输出

简单文件输入/输出

一、写入到文本文件中

文件输出必须包含头文件fstream,下面演示如何写入文件

ofstream outfile
outfile.open("test.txt")    //打开文件
outfile<<"abcd"

文件中:abcd

读取

ifstream infile;
double wt;

infile>>wt;
文件中:2.24

 

posted @ 2020-11-15 11:32  PYozo_free  阅读(142)  评论(0编辑  收藏  举报