title: Access the next word/string
body: <p>I have a simple C-based code to read a file. Read the input line by line. Tokenize the line and prints the current token. My problem is, I want to print the next token if some conditions are satisfied. Do you have any idea how to do it. I really need your help for this project. Thank you 
  Here is the code:</p>
  
  <pre><code>main(){
  
  FILE *input;
  FILE *output;
  //char filename[100];
  
  const char *filename = "sample1.txt";
  input=fopen(filename,"r");
  output=fopen("test.st","w");
  char word[1000];
  char *token;
  int num =0;
  char var[100];
  
  fprintf(output,"LEXEME, TOKEN");
  while( fgets(word, 1000, input) != NULL ){ //reads a line
  
  token = strtok(word, " \t\n" ); // tokenize the line    
  while(token!=NULL){ // while line is not equal to null
      fprintf(output,"\n");
      if (strcmp(token,"SIOL")==0)
          fprintf(output,"SIOL, SIOL", token);
      else if (strcmp(token,"DEFINE")==0)
          fprintf(output,"DEFINE, DEFINE", token);
      else if (strcmp(token,"INTEGER")==0){
          fprintf(output,"INTEGER, INTEGER");
          strcpy(var,token+1);
          fprintf(output,"\n%s,Ident",var);
      }
      else{
          printf("%s\n", token);
      }       
      token = strtok(NULL, " \t\n" ); //tokenize the word     
  }}fclose(output);return 0;}
  </code></pre>