title: Read sentences from file
body: <p>Strings are driving me crazy. It's like no buit-in function is useful. </p>
  
  <p>What I want to do is this. I've got this file f:</p>
  
  <pre><code>1
  I like fries
  2
  Do you like fries?
  3
  I like trains. 
  </code></pre>
  
  <p>How can I read the ENTIRE sentence "I like fries" from a file? So far nothing has worked for me. I do not know how long the sentence is and the variable I am reading / saving the sentence into is <code>char *Blaa;</code></p>
  
  <p>ok EDIT cause this is driving me crazy</p>
  
  <p>I've got this</p>
  
  <pre><code>     typedef struct Student
  {
  int nrcrt;
  char *name;
  } Student;
  Student *S;
  
    void Readstuff()
  {
  FILE *f;
  int i;
  f = fopen("students.txt","r");
  if (!f)
  {
      perror("can't open file.\n"); exit(EXIT_FAILURE);
  }
  char line[4096];
  for(i=0;i&lt;N;i++)
  {
  
     fscanf(f,"%d",&amp;S[i].nrcrt);
     printf("%d\n",S[i].nrcrt);
     while (fgets(line,sizeof(line),f) != 0)
      {
         strcpy(S[i].name,line);
      }
  }
  close(f);
  }
  </code></pre>
  
  <p>I can read ints into S[i].nrcrt, but if I want to read a string an put it in a S[i].name, the entire universe explodes. I keep getting segmentation fault. I tried to read a line in a variable <code>line</code> and then copy it into <code>S[i].name</code> but nothing. </p>
  
  <p>Let's pretend for the sake of argument a student's name can be "I like fries". I didn't want to overcomplicate the question so this is why I didn't actually say what I needed.</p>