Assignment 3 - Bitwise processing a binary file

due Tuesday, 2/2   1:30 pm

This assignment will give you practice processing a binary file, using standard output manipulators, and performing bitwise operations.

Program Steps

  1.  This file contains an unknown number of int values stored in binary.  Download the file.  Open it, determine the file size and number of int values that it contains.
  2.  Allocate memory dynamically to hold the int data from the binary file. 
  3.  Read the binary file into the dynamically allocated memory.
  4.  Display each int value in decimal, with a width of 12, six to a line.
  5.  Display each int value in hexadecimal, with a width of 12, six to a line.
  6.  Toggle the 2nd and 3rd bytes of each int and display each int value in hexadecimal, with a width of 12, six to a line.
  7.  Extract the 2rd byte of each int and display it in hexadecimal, with a width of 6, twelve to a line.
  8.  Reverse (flip) the nibbles of  the resulting byte and display it in hexadecimal, with a width of 6, twelve to a line.
  9.  Interpret each result from step 8 as a BCD (binary coded decimal) value and add 32 to each.  Cast each result to a char and display the secret message.
  10.  Clean up your mess.

Your output should look like this:

The file size is ??? bytes
The file contains ?? ints

  -691217343  2072452755   694768045  1875359246   241714198   344476761
   610911096  -202391194  -605052430  -469763768 -1198907060  -311905737
 -1129888652  1509941500 -1518763274  -943138080 -1569117388    67070218
 ...
   447333131 -1162400729  -674745868   174602911 -1502035352  -658606682


  0xd6ccdc41  0x7b871e93  0x296951ad  0x6fc7b60e   0xe684416  0x14884c59
  0x2469c378  0xf3efc166  0xdbefa1f2  0xe3fff948  0xb88a214c  0xed68b237
  0xbca74474  0x59ffe0fc  0xa57982f6  0xc7c8dae0  0xa2792b34   0x3ff690a
 ...
  0x1aa9c30b  0xbab72c27  0xd7c831f4   0xa683a9f  0xa678c268  0xd8be75a6


  0xd6332341  0x7b78e193  0x2996aead  0x6f38490e   0xe97bb16  0x1477b359
  0x24963c78  0xf3103e66  0xdb105ef2  0xe3000648  0xb875de4c  0xed974d37
  0xbc58bb74  0x59001ffc  0xa5867df6  0xc73725e0  0xa286d434   0x300960a
...
  0x1a563c0b  0xba48d327  0xd737cef4   0xa97c59f  0xa6873d68  0xd8418aa6

  0x33  0x78  0x96  0x38  0x97  0x77  0x96  0x10  0x10     0  0x75  0x97
  0x58     0  0x86  0x37  0x86     0  0x37  0x48  0x10     0  0x75  0x97
  0x58     0  0x27  0x56  0x68  0x96     0  0x76  0x97  0x77   0x8  0x67
...
  0x76  0x96  0x67  0x96  0x66  0x28  0x56  0x48  0x37  0x97  0x87  0x41

  0x33  0x87  0x69  0x83  0x79  0x77  0x69   0x1   0x1     0  0x57  0x79
  0x85     0  0x68  0x73  0x68     0  0x73  0x84   0x1     0  0x57  0x79
  0x85     0  0x72  0x65  0x86  0x69     0  0x67  0x79  0x77  0x80  0x76
...
  0x67  0x69  0x76  0x69  0x66  0x82  0x65  0x84  0x73  0x79  0x78  0x14

Awe ... ??? ... .