title: C Language: Search text file for a "word" and store the value into int and flout type variables
body: <p>For example text file (vars.txt) contains:</p>
  
  <pre><code>var1
  10
  var2
  3.54
  var3
  10110
  </code></pre>
  
  <p>I want to read the text file and store the value of var1 (which is the next line after var1 in text file) into a variable in my program.
  I have the following code but seems not working:</p>
  
  <pre><code>char cBuffer[256];
  FILE *pSrcFile;
  pSrcFile = fopen("vars.txt","r");
  while( (fgets( cBuffer, 256 , pSrcFile)) != NULL )
  {
      if( strcmp( cBuffer, "var1" ) != NULL )
      {
          sscanf( pSrcFile, "%d" , &amp;var1 );
          printf("var1 is found= %d",var1);
          break;
      }
  }
  </code></pre>
  
  <p>How can I convert and save strings of a text file into int, flout, and binary type variables?</p>
  
  <p>In other words, I want to search the text file to find "var1" and then save the next line (the value of "var1") to an integer variable and repeat this to search and store the value of "var2" into a float variable and "var3" into a binary variable an so on.</p>