#include <Windows.h>
#include <iostream>
#include <fcntl.h>
#include <fstream>
using namespace std;
int main(int argc,char ** argv)
{
ofstream outfile;
outfile.open("x:\\myfile_00.dat");
char ch1[16] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
int a = sizeof(ch1);
char * pCh = new char[17];
memset(pCh,0,16);
pCh[16] = 45;
memcpy(pCh, ch1, 16);
if (outfile.is_open())
{
for (int i = 0; i < 128; i++)
{
for (int j = 0; j < 1 ; j++)
{
outfile.write(ch1,16);
}
}
outfile.close();
}
else
{
cout << "can not open the file \n" << endl;
return -1;
#include <iostream>
#include <fcntl.h>
#include <fstream>
using namespace std;
int main(int argc,char ** argv)
{
ofstream outfile;
outfile.open("x:\\myfile_00.dat");
char ch1[16] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
int a = sizeof(ch1);
char * pCh = new char[17];
memset(pCh,0,16);
pCh[16] = 45;
memcpy(pCh, ch1, 16);
if (outfile.is_open())
{
for (int i = 0; i < 128; i++)
{
for (int j = 0; j < 1 ; j++)
{
outfile.write(ch1,16);
}
}
outfile.close();
}
else
{
cout << "can not open the file \n" << endl;
return -1;
}
system("pause");
return 0;
}
二进制文件中显示:00 01 02 03 04 05 06 07 08 09 0D 0A 0B 0C 0D 0E
0F