title: Writing and reading unsigned chars to binary file
body: <p>I am writing a simple program that writes to a binary file, closes it and then reads the data that was just written. I am trying to write an array of unsigned characters. I am experiencing some issues while reading the data. I am not exactly sure if I am writing the data improperly or reading it wrong. When I read the data I get my output as: <code>5 bytes</code> for the number of bytes read, but the output I got was not the same as the values I had wrote to the file.</p>
  
  <pre><code>FILE *binFile = fopen("sample","wb");
  
  unsigned char data[5]={5,10,15,20,25};
  fwrite(data,sizeof(unsigned char),sizeof(data),binFile);
  fclose(binFile);
  
  unsigned char data2[5];
  binFile = fopen("sample","rb");
  int s = fread(data2,1,sizeof(data),binFile);
  fclose(binFile);
  cout&lt;&lt;s&lt;&lt;" bytes\n";
  for(int i=0; i&lt;5;i++)
          cout&lt;&lt;data2[i]&lt;&lt;" ";
  cout&lt;&lt;"\n";
  </code></pre>