title: how to write and read points to binary file?
body: <p>I've programmed a code in C++ of a ball that moves in the space (3D points). I have all its movements positions. I mean, all the path points it passed.</p>
  
  <p>I have to write its all positions\points into a binary file and then read it in order to restore the movements\path. for example, if I move the ball up and right, I'll want to save all the positions it passed so then I can read them and draw the ball moves the same, restore its path.</p>
  
  <p>I saw an example for binary file but it doesn't say much to me:</p>
  
  <pre><code> // reading a complete binary file
   #include &lt;iostream&gt;
   #include &lt;fstream&gt;
   using namespace std;
  
   ifstream::pos_type size;
   char * memblock;
  
   int main () {
     ifstream file ("example.bin", ios::in|ios::binary|ios::ate);
     if (file.is_open())
     {
       size = file.tellg();
       memblock = new char [size];
       file.seekg (0, ios::beg);
       file.read (memblock, size);
       file.close();
  
       cout &lt;&lt; "the complete file content is in memory";
  
       delete[] memblock;
     }
     else cout &lt;&lt; "Unable to open file";
     return 0;
   }
  </code></pre>
  
  <p>Does it create the file automatically? Then where? And what about writing and reading points (X,Y,Z) ? Should I write it through binary bytes? or as points and the file makes it binary..?</p>