fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. if (argc != 3) {
  7. fprintf(stderr, "wrong arguments\n");
  8. return 1;
  9. }
  10.  
  11. FILE *f1 = fopen(argv[1], "rt");
  12. FILE *f2 = fopen(argv[2], "rt");
  13.  
  14. if (!f1 || !f2) {
  15. perror("pizdariki");
  16. return 1;
  17. }
  18.  
  19. char string1[1024];
  20. char lineno1 = 0;
  21.  
  22. while (fgets(string1, sizeof(string1), f1)) {
  23. ++lineno1;
  24.  
  25. char string2[1024];
  26. char lineno2 = 0;
  27. rewind(f2);
  28.  
  29. while (fgets(string2, sizeof(string2), f2)) {
  30. ++lineno2;
  31.  
  32. if (strcmp(string1, string2) == 0) {
  33. printf("matched '%s:%i' and '%s:%i':\n> %s\n", argv[1], lineno1, argv[2], lineno2, string1);
  34. }
  35. }
  36. }
  37. }
  38.  
Runtime error #stdin #stdout #stderr 0s 9296KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
wrong arguments