title: C++ editing text file using ofstream
body: <p>I am currently trying to manipulate the text of a text file (without using vectors):</p>
  
  <p>(This is for an assignment for an engineering paper, and I'm not allowed to use vectors)</p>
  
  <p>Variable numRows can be any integer (I chose 3 just for this example) and is a square matrix of elements in my output text file 'example.txt'</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  int main () {
  
  int numRows = 3;
  
    ofstream myfile ("example.txt");
    if (myfile.is_open())
    {
      for (int i = 0; i &lt; numRows; i++) {
      for (int j = 0; j &lt; numRows; j++) {
      myfile &lt;&lt; "Test\t";
      } 
      myfile &lt;&lt; "\n";
      }
      myfile.close();
    }
  
    else cout &lt;&lt; "Unable to open file";
  
    return 0;
  }
  </code></pre>
  
  <p>The text file is as follows:</p>
  
  <pre><code>Test    Test    Test    
  Test    Test    Test    
  Test    Test    Test    
  </code></pre>
  
  <p>My question is, once I've done all of this - how do I open it again and edit it? Eg. say I wanted to edit row 2, column 2 to "Hello":</p>
  
  <pre><code>Test    Test    Test    
  Test    Hello   Test    
  Test    Test    Test    
  </code></pre>
  
  <p>How would I do this? I need to be able to manipulate the strings stored in this text file and am unsure of what to do since I have separated each string by the tab character</p>
  
  <p>Thank you for taking the time to help!</p>