title: Writing and Reading from a file at the same time
body: <p>I've been trying to read and write from a file at the same time and I'm trying to substitute all the tabs in the content of text.txt to be turned into spaces. This is my code:</p>
  
  <pre><code>int main()
  {
     FILE* filePtr = fopen("text.txt", "w+");
  
     char c;
     c = fgetc(filePtr);
     fpos_t num;
     while(c != EOF)
     {
         if(c == '\t')
         {
             fgetpos(filePtr, &amp;num);
             num--;
             fsetpos(filePtr, &amp;num);
             fputc(' ', filePtr);
         }
         c = fgetc(filePtr);
     }
  }
  </code></pre>
  
  <p>The content of text.txt is as such:</p>
  
  <p>Hi \t my \t name \t is \t jack!</p>
  
  <p>When I run this code, my output in the text.txt file is just blank space. There are no characters there. What should I do so that the substitutions work out as intended? </p>