cpp ofstream ifstreram binary 文档读写

简介: cpp ofstream ifstreram binary 文档读写

include

include

include

include

include <sys/stat.h>

include

void test_copy_binary(std::string src,std::string dst){
std::ofstream ostrm(dst,std::ios::binary);
std::ifstream istrm(src,std::ios::binary);
if (!istrm.is_open() )
    {
        std::cout<<"failed to open: "<<src<<std::endl;
return ;
    }
if (!ostrm.is_open())
    {
        std::cout<<"failed to open: "<<dst<<std::endl;
return ;
    }
    {
char buf[1];
while(1){
            istrm.read(buf,1);
if(istrm.eof())
            {
break;
            }
            ostrm.write(buf,1);
            istrm.seekg(1024);
        }
        istrm.close();
        ostrm.close();
    }
}
目录
相关文章
|
2月前
|
C++
cpp 获取文件是否存在 获取文件大小
cpp 获取文件是否存在 获取文件大小
33 0
|
10月前
使用FILE结构操作文本文件
使用FILE结构操作文本文件
|
11月前
|
存储 C语言 iOS开发
【C++】标准库 - 文件的读写 i/ofstream
本文章介绍 C++ 标准库中处理文件读写的 fstream ,以及其中的一些使用
137 0
|
12月前
file_get_contents和strstr防止文件关键内容被删除
file_get_contents和strstr防止文件关键内容被删除
24 0
C++ 中 ifstream读取txt文件内容
C++ 中 ifstream读取txt文件内容
1245 0
C++ 中 ifstream读取txt文件内容
|
12月前
ENVI_IDL: 文本文件的读取(主要是txt、csv文件)
ENVI_IDL: 文本文件的读取(主要是txt、csv文件)
344 0
|
存储 C++ iOS开发
【C++之文件与文件流】f1.dat 和 f2.dat 文件的读写
【C++之文件与文件流】f1.dat 和 f2.dat 文件的读写
C#编程:File.Open获取文件字节大小-8
C#编程:File.Open获取文件字节大小-8
|
C语言
【C 语言】文件操作 ( 使用 fread 和 fwrite 实现二进制文件的拷贝 | stat 统计文件大小 | feof 判定文件结尾 )
【C 语言】文件操作 ( 使用 fread 和 fwrite 实现二进制文件的拷贝 | stat 统计文件大小 | feof 判定文件结尾 )
291 0
【C 语言】文件操作 ( 使用 fread 和 fwrite 实现二进制文件的拷贝 | stat 统计文件大小 | feof 判定文件结尾 )
C#编程:File.Open获取文件字节大小
C#编程:File.Open获取文件字节大小
286 0