title: Reading a binary file into a global unsigned int
body: <p>Im attempting the starts of a VM in C and i'm attempting to understand how to read out the binary file ive produced from the assembler. As per instructions of assignment we are to allocate a global memory as an unsigned byte of 1k memory space and and then using a load function are to read this binary file into the memory and then using a fetch function read these bytes into their instructions. The issue im having is part 1, how do i read this binary file into this unsigned int array and then decode it in a way that can be worked with? At the moment what i have prints out a value that isnt at all what is to be expected. </p>
  
  <p><strong>MAIN.c</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdbool.h&gt;
  #include &lt;stdlib.h&gt;
  
  unsigned int memory[1028];
  
  int loads(char *filename){
       FILE *file = fopen(filename, "r");
       ssize_t read;
       if(file == NULL){
           exit(-1);
       }
  
       while(fread(&amp;memory, sizeof(unsigned int), 1, file) == 1){
           printf("%d\n", *memory);
       }
      fclose(file);
      exit(0);
  }
  
  int main(int argc, char** argv){
      if (argc &lt;= 1){
          printf("No file found\n");
          return -1;
      }
  
      char *filename = argv[1];
  
      loads(filename);
  }
  </code></pre>
  
  <p><strong>inputfile.txt</strong></p>
  
  <p>t@w@# (this is what it shows which is unreadable but when using <code>od -t x1 output.txt | head -5</code> it prints out to be <code>0000000 74 40 77 40 11 23
  0000006</code>)</p>
  
  <p><strong>Current Output</strong>
  1081557108</p>
  
  <p><strong>Desired output</strong>
  74 40 77 40 11 23</p>