fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(void)
  6. {
  7. FILE *fp, *nf;
  8. char ch;
  9.  
  10. if ((fp = fopen("origpic", "r")) == NULL)
  11. {
  12. fprintf(stderr, "Can't open file\n");
  13. exit(EXIT_FAILURE);
  14. }
  15.  
  16. if ((nf = fopen("newpic", "w+")) == NULL)
  17. {
  18. fprintf(stderr, "Cannot create new file\n");
  19. exit(EXIT_FAILURE);
  20. }
  21.  
  22. while ((ch = getc(fp)) != EOF)
  23. {
  24. if (ch != '\n')
  25. {
  26. putc(ch, nf);
  27. putc(' ', nf);
  28. }
  29. else putc('\n', nf);
  30. }
  31.  
  32. fclose(fp);
  33. fclose(nf);
  34.  
  35. return 0;
  36. }
  37.  
Runtime error #stdin #stdout #stderr 0s 4636KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Can't open file