title: Trying to read in two lines using fgets. Why is it only reading the first line?
body: <p>I am trying to read in two lines using fgets, but only the first line is read and then returns a segmentation fault. I'm not sure what I would need to change for it to read in the second line. Any help would be appreciated!</p>
  
  <pre><code>int main(void)
  {
    char str[100];
    char *word;
  
    //First Line                                                                                        
    fgets(str, 100, stdin);
    printf("%s", str);
  
    word = strtok(str," ");
    printf("%s\n", word);
  
    while(word != NULL)
      {
        word = strtok(NULL," ");
        printf("%s\n", word);
    }
  
    //Second Line                                                                                       
    fgets(str, 100, stdin);
    printf("%s", str);
  
    word = strtok(str," ");
    printf("%s\n", word);
  
    while(word != NULL)
      {
        word = strtok(NULL," ");
        printf("%s\n", word);
      }
  
    return 0;
  }
  </code></pre>