Enter the code:
/* Copyright (c) 2014, Yantai University School of Computer * All rights reserved. * File name: Sum123.cpp * Author: Lin Haiyun * Completion Date: August 19, 2015 * Version number: v2.0 * * Problem Description: Do a similar binaryviewer view binary files, enter the file name, can be 16 binary The contents of the file are listed in the ASCII-controlled manner * Input Description: Enter the file name; * Program output: The contents of the file in 16 binary format output */#include <fstream> #include <string> #include <iostream> #include <iomanip> #include <cstdlib>using namespace Std;int main () {char c[16]; Char f[100]; cout<< "Please enter the file name:"; cin>>f; Ifstream infile (f,ios::in|ios::binary); if (!infile) {cerr<< "Open error!" <<endl; Abort (); } while (!infile.eof ()) {infile.read (c,16); if (!infile.eof ()) {for (int i=0; i<16; i++) Cout<<setfill (' 0 ') <<SETW (2) < ;
Operation Result:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Binary file Browser