title: How do I write to a specific line of file in c?
body: <p>So I have a project I am doing and I have created a program that allows the user to write to a file, as shown below:</p>
  
  <pre><code> #include &lt;stdio.h&gt;
   #include &lt;stdlib.h&gt;
  
   FILE *fd;
   FILE *fw;
  
       struct store
       {
            char Word[512];
            char NWord[512];
       }
       stock;
  
       struct store2
       {
            char Definition[512];
       }
       stock2;
  
  char done='y';
  int count=1;
  int c=0;
  int d=0;
  
  int main(void)
  {
      fw=fopen("Test Z W.txt","w");
      fd=fopen("Test Z D.txt","w");
  
      do
      {    
           printf("Word %d: ",count);
           gets(stock.Word);
           while((c= getchar()) != '\n' &amp;&amp; c != EOF);
  
           printf("Definition %d: ",count);
           gets(stock2.Definition);
           while((c= getchar()) != '\n' &amp;&amp; c != EOF);  
  
           fprintf(fw,"%s\n", stock.Word);         
           fprintf(fd,"%s\n", stock2.Definition);        
           count=count+1;  
           system("cls");                
      }
      while (count&lt;11);
  
  fclose(fd);
  fclose(fw);
  
  return 0;
  
  }
  </code></pre>
  
  <p>this code is fine, however, I would like to expand it so that there is an option to edit just one chosen line, rather than wiping the entire file and writing all of the contents again. </p>
  
  <p>All I have to work on is using 
  <a href="https://stackoverflow.com/questions/22798537/how-do-you-write-to-a-specific-line-of-a-txt-file-in-c">How do you write to a specific line of a txt file in C?</a> </p>
  
  <p>Which wasn't very helpful since I couldn't take an answer and import it to my code, either way all I need is something where an error such as the one below, can be fixed easily.</p>
  
  <pre><code> 1
   2
   Three
   4
   5
   6
   7
   8
   9
   10
  </code></pre>
  
  <p>Where the user will automatically be asked which line they want to edit.</p>