title: How to build array from a text file in C
body: <p>Im writing a program where I insert strings that are from a text file into an array. I already have the insert function written, but im confused as how to run through the text file string by string.</p>
  
  <p>Essentially in the main() function the program needs to setup an array, then run thought the file opened and use the insert function on each string in the file. So how would I go about taking each string, using it in the insert function and then moving on to the next string in the file. </p>
  
  <p>If more clarification is needed let me know! Thanks.</p>
  
  <p>Updated with Insert and main functions:</p>
  
  <p>The insert function inserts the string word into Table, which should be maintained  in  sorted  order. it Returns n+1 if the string is successfully inserted;   otherwise returns n. It uses binary search.</p>
  
  <pre><code>int insert(char *word, char *Table[], int n){
  
      int low = 0;
      int high = n;
      int mid;
      int index = -1;
      int k;
  
      while (low &lt; high)
      {
          mid = low  +  (high - low)/2;
          if (strcmp(Table[mid], word) == 0)
          {
              index = mid;
              break;
          }
          else if (strcmp(Table[mid], word) &lt; 0)
              low = mid  +  1;
          else
              high = mid - 1;
      }
      if (index != -1 &amp;&amp; index &lt; n)
          return n;
  
      for (index = 0; index &lt; n; index++)
      {
          if (strcmp(Table[index], word) &lt; 0)
              continue;
          else
              break;
      }
      for (k = n-1; k &gt;= index; k--)
      {
          Table[k + 1] = Table[k];
      }
      Table[index] = strdup(word);
  
      return n + 1;
  }
  </code></pre>
  
  <p>Main:</p>
  
  <p>Command line should be something like this "./concordance 15 &lt; input.txt"</p>
  
  <pre><code>int main(int argc, char *argv[]){
  
  FILE *fp = fopen(argv[3], "r");
  int n = atoi(argv[1]);
  int insert;
  char *Table[n];
  </code></pre>
  
  <p>Im stuck in the main function so its incomplete.
  Also the a "word" in this file, which I meant by string, is classified with a punctuation character of space, period, comma, semicolon,colon,   exclamation 
  point, double quote, question mark, and newline character. But apostrophe is still considered part of the word.</p>