title: C programing How do i get a specific line of strings from a text file?
body: <p>I've been tasked to create a program that will input a number, and the program will then open a file and retrieve the string on that given sentence. Here is the text file i am working with.</p>
  
  <pre><code>billy
  bob
  james
  peter
  mike
  kieran
  obidiah
  scarlett
  john
  chloe
  sarah
  bob
  leon
  david
  andrew
  james
  shawn
  hannah
  peter
  phoebe
  chris
  john
  mark
  meg
  </code></pre>
  
  <p>Now, i decided it was easier to get a name, get a count value and reverse engineer it from there, however i am completely stuck on how to do it, can anyone help?</p>
  
  <pre><code>   int main(int argc, char *argv[]) {
      int count = 1;
  
      char wd[20], word[20];
  
      FILE *fp;
  
      fp = fopen("Names.txt", "r");
      if (fp == NULL) {
          printf("given file doesn't exist");
          getch();
      } else {
          printf("Name: ");
          scanf("%s", word);
          fscanf(fp, "%s", wd);
          while (!feof(fp)) {
              if (strcmp(word, wd) == 0) {
                  printf("%s found in the file. the given word is the %d word in the file", word, count);
                  count = 0;
                  break;
              } else {
                  fscanf(fp, "%s", wd);
                  count++;
              }
          }
          if (count != 0) {
              printf("given word is not found in the file");
          }
          getch();
      }
  }
  </code></pre>
  
  <p>This is the name to line code, I would like the count to name code.</p>