Check out example codes for "fstream "seekp"". It will help you in understanding the concepts better.

Code Example 1

std::ostream::seekp
(1)	
ostream& seekp (streampos pos);
(2)	
ostream& seekp (streamoff off, ios_base::seekdir way);
Set position in output sequence
Sets the position where the next character is to be inserted into the output stream.

 ***********  Example:   ************

// position in output stream
#include <fstream>      // std::ofstream

int main () {

  std::ofstream outfile;
  outfile.open ("test.txt");

  outfile.write ("This is an apple",16);
  long pos = outfile.tellp();
  outfile.seekp (pos-7);
  outfile.write (" sam",4);

  outfile.close();

  return 0;
}

Code Example 2

// position in output stream
#include <fstream>      // std::ofstream

int main () {

  std::ofstream outfile;
  outfile.open ("test.txt");

  outfile.write ("This is an apple",16);
  long pos = outfile.tellp();
  outfile.seekp (pos-7);
  outfile.write (" sam",4);

  outfile.close();

  return 0;
}

Learn ReactJs, React Native from akashmittal.com