fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. const char* file0 = "5-1.txt";
  6. const char* file1 = "5-2.txt";
  7. const int BUF_SIZE = 256;
  8.  
  9. int main(void) {
  10. char buffer0[BUF_SIZE];
  11. char buffer1[BUF_SIZE];
  12. FILE *fp0 = fopen(file0, "r");
  13. FILE *fp1 = fopen(file1, "r");
  14. char* p;
  15.  
  16. while((fgets(buffer0, BUF_SIZE, fp0)) && fgets(buffer1, BUF_SIZE, fp1)) {
  17. if (strcmp(buffer0, buffer1) == 0) {
  18. p = strchr(buffer0, '\n');
  19. *p = '\0';
  20. puts(buffer0);
  21. } else {
  22. puts("*");
  23. }
  24. }
  25.  
  26. return EXIT_SUCCESS;
  27. }
  28.  
  29.  
Runtime error #stdin #stdout 0s 5460KB
stdin
Standard input is empty
stdout
Standard output is empty