title: How to read big endian integers from file in C++?
body: <p>Say I have a binary file; it contains positive binary numbers, but written in big endian as 32-bit integers</p>
  
  <p>How do I read this file? I have this right now.</p>
  
  <pre><code>int main() {
      FILE * fp;
      char buffer[4];
      int num = 0;
      fp=fopen("file.bin","rb");
      while ( fread(&amp;buffer, 1, 4,fp) != 0) {
  
          // I think buffer should be 32 bit integer I read,
          // how can I let num equal to 32 bit big endian integer?
      }
      return 0;
  }
  </code></pre>