Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #define USE_UPTR
- #if defined(USE_UPTR)
- #include <memory>
- #endif
- using namespace std;
- int main( int argc, char* argv[] ){
- if( argc < 2 ){
- cout << "No input file...\n";
- return 1;
- }
- ifstream getfilesize( argv[1], ios::binary | ios::ate);
- if( !getfilesize.good() ){
- cout << "Can't open file...\n"<<argv;
- return 1;
- }
- size_t file_size = static_cast<size_t>(getfilesize.tellg());
- getfilesize.close();
- if( file_size ){
- #if defined(USE_UPTR)
- std::unique_ptr<char> bufer(new char[file_size]);
- auto p = bufer.get();
- #else
- char* p = new char[file_size];
- #endif
- ifstream file( argv[1], ios::binary);
- file.read(p, file_size);
- for(std::size_t i = 0; i < file_size; ++i){
- if( p[i] == 0x0 ) cout << "[NUL]";
- else if( p[i] == 0x1 ) cout << "[SOH]";
- else if( p[i] == 0x2 ) cout << "[STX]";
- else if( p[i] == 0x3 ) cout << "[ETX]";
- else if( p[i] == 0x4 ) cout << "[EOT]";
- else if( p[i] == 0x5 ) cout << "[ENQ]";
- else if( p[i] == 0x6 ) cout << "[ACK]";
- else if( p[i] == 0x7 ) cout << "[BEL]";
- else if( p[i] == 0x8 ) cout << "[BS]";
- else if( p[i] == 0x9 ) cout << "[HT]";
- else if( p[i] == 0x0A ) cout << "[LF]";
- else if( p[i] == 0x0B ) cout << "[VT]";
- else if( p[i] == 0x0C ) cout << "[FF]";
- else if( p[i] == 0x0D ) cout << "[CR]";
- else if( p[i] == 0x0E ) cout << "[SO]";
- else if( p[i] == 0x0F ) cout << "[SI]";
- else if( p[i] == 0x10 ) cout << "[DLE]";
- else if( p[i] == 0x11 ) cout << "[DC1]";
- else if( p[i] == 0x12 ) cout << "[DC2]";
- else if( p[i] == 0x13 ) cout << "[DC3]";
- else if( p[i] == 0x14 ) cout << "[DC4]";
- else if( p[i] == 0x15 ) cout << "[NAK]";
- else if( p[i] == 0x16 ) cout << "[SYN]";
- else if( p[i] == 0x17 ) cout << "[ETB]";
- else if( p[i] == 0x18 ) cout << "[CAN]";
- else if( p[i] == 0x19 ) cout << "[EM]";
- else if( p[i] == 0x1A ) cout << "[SUB]";
- else if( p[i] == 0x1B ) cout << "[ESC]";
- else if( p[i] == 0x1C ) cout << "[FS]";
- else if( p[i] == 0x1D ) cout << "[GS]";
- else if( p[i] == 0x1E ) cout << "[RS]";
- else if( p[i] == 0x1A ) cout << "[US]";
- else if( p[i] == 0x7F ) cout << "[DEL]";
- else cout << p[i];
- }
- #if !defined(USE_UPTR)
- delete []p;
- #endif
- }
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement