title: Reading a specific sequence of characters from text file in C
body: <p>If I`ve got a TXT file with a pre-determined structure, is there any way I can read some of the text directly from the file without having to parse or tokenize a string? For instance, if I have the following code:  </p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;cstring&gt;
  #include &lt;fstream&gt;
  
  int main(int argc, char** argv) {
      FILE* test = fopen("test.txt","w+");
      char* read;
      fprintf(test,"(foo,_TEMP71_,_,_)\n");
      fprintf(test,"(foo,_TEMP52_,_,_)\n");
      fprintf(test,"(foo,_TEMP43_,_,_)\n");
      fprintf(test,"(foo,_TEMP24_,_,_)\n");
      fprintf(test,"(foo,_TEMP15_,_,_)\n");
      fprintf(test,"(foo,_TEMP06_,_,_)\n");
      fseek(test, 0, SEEK_SET); //returns the file pointer to start of file
  
      while(feof(test) == 0)
      {
          fscanf(test, "_%s_", read); //or fscanf(test, "_TEMP%s_", read);
          printf("%s\n", read);
      }
  
      fclose(test);
  
  }
  </code></pre>
  
  <p>Note that on the <code>fscanf</code> line, I read from <a href="http://www.cplusplus.com/reference/cstdio/fscanf/?kw=fscanf" rel="nofollow noreferrer">this</a> website that you could specify a certain string of characters to be read, but I don`t think I understood quite how it works.</p>