快下课了,回顾了一下fstream

ofstream是从内存到硬盘,ifstream是从硬盘到内存;

 

fstream if("1.txt", ios::in);      // 表示 可以 从这个文件中(即:硬盘) 读取数据(即:读到内存中); 所以等价于:ifstream("1.txt");

fstream of("2.txt", ios::out);     // 表示 可以 从内存中 向 文件中写;  所以等价于:ofstream("2.txt");

你可能感兴趣的:(ios)