jQuery火箭图标返回顶部代码

c++ fstream用法

今天介绍一个复制 粘贴的函数,用fstream实现

#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;
}

 

示例展示:

原来的文件:

 

运行程序后:

posted @ 2018-05-21 12:27  迷途纸鸢  阅读(1655)  评论(0编辑  收藏  举报