title: How to read second and last words from each line in C
body: <p>I have a file with data like this</p>
  
  <p>{0   /<em>Data1</em>/               , 0x00,      0,  0xFF},</p>
  
  <p>{1   /<em>data2</em>/               , 0x00,      0,  0xFF},</p>
  
  <p>{2   /<em>data3</em>/               , 0x00,      0,  0xFF},</p>
  
  <p>{3   /<em>data4</em>/               , 0x00,      0,  0xFF},
  ...</p>
  
  <p>I want to print only the second and last column of each line. Below is the code I worked on. Its printing the whole line. How to edit  to print only the second and last column of each line.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  #include&lt;conio.h&gt;
  
  int main ()
  {       
      char filename[] = "file.txt"; 
  
      FILE *file = fopen(filename, "r");
  
      if(file!= NULL)     
      {                           
          char line[128];                 
  
          while ( fgets( line, sizeof line, file)!= NULL)
          {                                           
              fputs ( line,stdout);                           
          }                                                       
          fclose(file);                           
      }                                               
      else                    
      {                               
          perror(filename);                   
      }                                           
  
  
      getch();                    
  
      return 0;                       
  }        
  </code></pre>
  
  <p>Please Help!</p>
  
  <p>Thanks a ton!</p>