fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void task_main(FILE *fp1, FILE *fp2) {
  5. int c1, c2;
  6. while ((c1 = fgetc(fp1)) != EOF) {
  7. if ((c2 = fgetc(fp2)) == EOF)
  8. break;
  9. if (c1 == c2)
  10. fputc('1', stdout);
  11. else
  12. fputc('0', stdout);
  13. }
  14. }
  15.  
  16. int main(int argc, char *argv[]) {
  17. FILE *fp1, *fp2;
  18. if (argc != 3) {
  19. fprintf(stderr, "usage: %s <file1> <file2>\n", argv[0]);
  20. exit(1);
  21. }
  22. if ((fp1 = fopen(argv[1], "r")) != 0) {
  23. if ((fp2 = fopen(argv[2], "r")) != 0) {
  24. task_main(fp1, fp2);
  25. fclose(fp2);
  26. } else {
  27. fprintf(stderr, "cannot open the file '%s'.\n", argv[2]);
  28. }
  29. fclose(fp1);
  30. } else {
  31. fprintf(stderr, "cannot open the file '%s'.\n", argv[1]);
  32. }
  33. return 0;
  34. }
  35. /* end */
  36.  
Runtime error #stdin #stdout 0s 1784KB
stdin
Standard input is empty
stdout
Standard output is empty