Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. void diff(FILE *infile1, FILE *infile2, FILE *outfile)
  2. {
  3. char file1_line[MAX_LINE_LEN] = "";
  4. char file2_line[MAX_LINE_LEN] = "";
  5. int line_number = 0;
  6. int num_differences = 0;
  7.  
  8. /* Read a line from each file */
  9. fgets(file1_line, MAX_LINE_LEN, infile1);
  10. fgets(file2_line, MAX_LINE_LEN, infile2);
  11.  
  12. /* Change this into a loop through the infiles */
  13. for (line_number=1; line_number<=MAX_LINE_LEN; line_number++)
  14. {
  15.  
  16. if ( strcmp goes here )
  17. {
  18. fprintf(outfile, "File 1 (%d):%s",
  19. line_number, file1_line);
  20. fprintf(outfile, "File 2 (%d):%s",
  21. line_number, file2_line);
  22. num_differences++;
  23.  
  24. fgets(file1_line, MAX_LINE_LEN, infile1);
  25. fgets(file2_line, MAX_LINE_LEN, infile2);
  26. }
  27. }
  28.  
  29. /* Print the number of differences to the screen */
  30. printf("Number of differences found: %d\n", num_differences);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement