Posted By

somada141 on 03/12/10


Tagged

data file read binary stream


Versions (?)

Read arithmetic binary data using fstreams #1


 / Published in: C++
 

  1. int m;
  2. ifstream results("numbers.dat");
  3. results.read(reinterpret_cast < char * > (&m), sizeof(m));
  4. //note the fact that we recast the integer 'm' to a 'char' before reading in the value
  5.  
  6. /*
  7. read() returns a reference to ifstream so you retrieve multiple values as follows:
  8.  
  9. results.read(&c, sizeof(c)).read(&d, sizeof(d));
  10. */

Report this snippet  

You need to login to post a comment.