title: How to go to the beginning of the file in fstream?
body: <p>I'm practicing file handling. I made a text file and wrote some characters in it, now I want the cursor to go to the beginning of the file and put a character there using seekp.</p>
  
  <p>Here is the code</p>
  
  <pre><code>fstream ofile;
  
  char ch = 'g';
  
  ofile.open("test.txt", ios::out | ios::app);
  
  ofile.seekp(0, ios::beg);
  ofile.put(ch);
  
  ofile.close();
  </code></pre>
  
  <p><strong>Expected Result:</strong>
  It writes g at the start of file.</p>
  
  <p><strong>Actual Result:</strong>
  It appends g at the end.</p>
  
  <p>I tried removing the ios::app tag but ios::out alone truncates the file before writing anything.</p>