64,849
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc,char** argv)
{
fstream fsIn;
fstream fsOut;
char s[10]={0};
fsIn.open("cc.cpp",ios::in | ios::binary );
fsIn.read(s,10);
fsIn.close();
fsOut.open("1.txt", ios::out | ios::binary );
fsOut.write(s,10);
fsOut.close();
return 0;
}
void SaveToFile(char* buffer, int len)
{
ofstream ofs("byte.bin", ios::binary);
copy(buffer, buffer + len, ostream_iterator<char>(ofs));
ofs.close();
}