title: Compare 2 files
body: <p>I have a problem, I need to make a program which will compare two files.
  If in first file I have: </p>
  
  <pre><code>Milk
  Sugar
  Eggs
  </code></pre>
  
  <p>and in the second file I have</p>
  
  <pre><code>Vanilla
  Soda
  Sugar
  </code></pre>
  
  <p>I want to show the the line which appear in both files.</p>
  
  <p>I don't have a lot of experience with c, but I tried something.
  But my question is how I will show Sugar as output if they are not on the same line?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include&lt;string.h&gt;
  #define MAX 100
  
  void equal (char*lineone,char*linetwo){
      if(strcmp(lineone,linetwo)==0){
          printf("%s",lineone);
      }
  }
  int main(){
      FILE *fp1,*fp2;
      fp1=fopen("D:/aici/file1.txt","r");
      fp2=fopen("D:/aici/file2.txt","r");
      char buff[MAX],buff1[MAX];
      int i=0;
      while((fgets(buff,MAX,fp1)!=NULL)&amp;&amp;(fgets(buff1,MAX,fp2))!=NULL){
              //i++;
              equal(buff,buff1);
      }
  }
  </code></pre>