c++ fstream用法
生活随笔
收集整理的這篇文章主要介紹了
c++ fstream用法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
今天介紹一個復(fù)制 粘貼的函數(shù),用fstream實現(xiàn)
#include "stdafx.h" #include<iostream> #include<fstream> using namespace std; int main() {fstream in("a.jpg", ios_base::binary|ios_base::in);if (in.is_open()){fstream out("F:/1/nature.jpg", ios_base::binary|ios_base::out);if (out.is_open()){char* buf = new char[255];while (in.good()){in.read(buf, 255);int count = in.gcount();out.write(buf, count);}out.close();}in.close();}return 0; }?
示例展示:
原來的文件:
?
運行程序后:
轉(zhuǎn)載于:https://www.cnblogs.com/Trojan00/p/9066622.html
總結(jié)
以上是生活随笔為你收集整理的c++ fstream用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jsp button提交表单
- 下一篇: ES6-let和const命令