title: Reading a line from a text file into an array of characters in c
body: <p>I am trying to fill an array from a text file. the array is in a struct which is:</p>
  
  <pre><code>struct ISBN
  {
      long value;
  };
  struct Author
  { 
      char authorName[60];
  };
  struct  Book
  {
      char *bookTitle;
      struct Author bookAuthor;
      struct ISBN bookID;
  };
  </code></pre>
  
  <p>I tried to write a fillin function which takes the file and struct of type Book, like this:</p>
  
  <pre><code>void fillin (FILE * file, struct Book * bk)
  {
      bk-&gt;bookTitle =(char*) malloc(1000);
      size_t n = 0;
      int c;
  
      file=fopen("book.txt","r");
  
      while ((c = fgetc(file)) != '\n')
      {
          bk-&gt;bookTitle[n++] = (char) c;
      }
  
      bk-&gt;bookTitle[n] = '\0'; 
  
      fscanf(file,"%s", &amp;bk-&gt;bookAuthor.authorName);
      fscanf(file,"%lld",&amp;bk-&gt;bookID.value);
  
      //fscanf(file,"%s", &amp;bk-&gt;bookTitle);
  }
  </code></pre>
  
  <p>File  book.txt has this data:</p>
  
  <pre><code>UNIX Network Programming
  W. Richard Stevens
  0131411551
  </code></pre>
  
  <p>The problem is, it can not scan arrays and i want to fill bookTitle and autherName arrays from the textfile.</p>