前言
所需包含库:iostream和fstream,即:
#include<iostream>
#include<fstream>
数据描述 | 描述 |
---|---|
ofstream | 该数据类型表示输出文件流,用于创建文件并向文件写入信息。 |
ifstream | 该数据类型表示输入文件流,用于从文件读取信息。 |
fstream | 该数据类型通常表示文件流,且同时具有 ofstream 和 ifstream 两种功能,这意味着它可以创建文件,向文件写入信息,从文件读取信息 |
读取 & 写入实例
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
ifstream infile;
ofstream outfile;
string tmp;
bool ifirst=true;
unsigned int hh=0, min = 0, sec = 0, hh_tmp = 0, min_tmp = 0<