title: Best way to store the first and second word of a text file into two arrays
body: <p>I'm making a code for a program.
  It would have three text files: 
  -list1.txt having a column of words like:</p>
  
  <pre><code>Cat 
  Dog
  Fish 
  Computers
  </code></pre>
  
  <p>-change.txt having two columns of text like</p>
  
  <pre><code>Dog  Marbles
  Computers Store
  </code></pre>
  
  <p>-list2.txt being empty</p>
  
  <p>The program would take list.txt, and store its words in the list2.txt, only if a word would be the first column word in change, it would store the word from the second column. 
  That way, when the program would compile, the list2.txt would look like this:</p>
  
  <pre><code>Cat 
  Marbles
  Fish 
  Store
  </code></pre>
  
  <p>The way I thought of doing this was to make two char arrays, one for the first column word, and the second for....well, the second one. Then mane a nice if and write the second value if true.
  The problem is I can't figure a good way to store those words in the arrays correctly.</p>
  
  <p>Here's my code for now:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  {
      ///////////OPENING THE TEXT FILES
  FILE *sp ;
  sp= fopen("list.txt", "r");
  if(sp==NULL){
  printf("can't open list");
  exit(1);
  }
  
  FILE *change;
  change = fopen("change.txt", "r");
  if(change==NULL){
  printf("can't open change");
  exit(1);
  }
  
  FILE *sp2;
  sp2 = fopen("list.txt", "w");
  if(sp2==NULL){
  printf("can't open list2");
  exit(1);
  }
  
  char word[100]; 
  char key[20]; //the char array for the element TO replace
  char mod[20]; //the char array for the element TO BE replaced
  
  while(fscanf(sp, "%s", word)==1){
      fprintf(sp2, "%s\n", word);} //the copy machine
  
  fclose(sp);
  fclose(sp2);
  return 0;
  }
  </code></pre>
  
  <p>Any help here would be appreciated.</p>