title: Writing unsigned int to binary file
body: <p>My first time working with binary files and I'm having clumps of hair in my hands.  Anyway, I have the following defined:</p>
  
  <pre><code>unsigned int cols, rows;
  </code></pre>
  
  <p>Those variables can be anywhere from 1 to about 500.  When I get to writing them to a binary file, I'm doing this:</p>
  
  <pre><code>    myFile.write(reinterpret_cast&lt;const char *&gt;(&amp;cols), sizeof(cols));
      myFile.write(reinterpret_cast&lt;const char *&gt;(&amp;rows), sizeof(rows));
  </code></pre>
  
  <p>When I go back to read the file, on <code>cols = 300</code>,  I get this as result:</p>
  
  <pre><code>44
  1
  0
  0
  </code></pre>
  
  <p>Can someone please explain to me why I'm getting that result?  I can't say that there's something wrong, as I honestly think it's me who don't understand things.  What I'd LIKE to do is store the value, as is, in the file so that when I read it back, I get that as well.  And maybe I do, I just don't know it.</p>
  
  <p>I'd like some explanation of how this is working and how do I get the data I put in read back.</p>