title: reading first line of a file in c
body: <p>I am very new to C and I am having trouble with the most fundamental ideas in C.  We are starting structures and basically the assignment we are working on is to read a delimited file and save the contents into a structure.  The first line of the file has the number of entries and alls that I am trying to do at the moment is get the program to read and save that number and print it out.  Please do not assume I know anything about C I really am very new to this.</p>
  
  <p>This code is giving me a segmentation fault</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  
  struct info{
    char name[100];
    char number[12];
    char address[100];
    char city[20];
    char state[2];
    int zip;
  };
  
  int strucCount;
  char fileText[1];
  
  int main(char *file)
  {
    FILE *fileStream = fopen(file, "r");
    fgets(fileText, 1, fileStream);
  
    printf("\n%s\n",fileText);
  
    fclose(fileStream);
  
  }
  </code></pre>
  
  <p>Here is the sample file</p>
  
  <pre><code>4
  mike|203-376-5555|7 Melba Ave|Milford|CT|06461
  jake|203-555-5555|8 Melba Ave|Hartford|CT|65484
  snake|203-555-5555|9 Melba Ave|Stamford|CT|06465
  liquid|203-777-5555|2 Melba Ave|Barftown|CT|32154
  </code></pre>
  
  <p>Thanks for everyones comments, they helped a lot, sorry to Jim.  I am working on very little sleep and didn't mean to offend anyone, I am sure we have all been there haha.</p>