主代码如下:
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{
ofstream inputfile("./xyz.dat", ios_base::out | ios_base::trunc);
if (!inputfile.is_open())
{
cout << "open filed failed!" << endl;
return -1;
}
int i = 0;
char buff[128] = {0};
for (i = 0; i < 256; ++i)
{
sprintf(buff, "%-8d
0%08o
Ox%08x\n", i, i, i);
cout << buff << endl;
inputfile << buff;
memset(buff, 0, sizeof(buff));
}
inputfile.close();
getchar();
return 0;
}