Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fclose returns EOF on error

...

Code Block
bgColor#FFcccc
langc
#include <stdio.h>
 
int close_stdout(void) {
  if (fclose(stdout) !== 0EOF) {
    return -1;
  }
 
  printf("stdout successfully closed.\n");
  return 0;
}

...

Code Block
bgColor#ccccff
langc
#include <stdio.h>
 
int close_stdout(void) {
  if (fclose(stdout) !== 0EOF) {
    return -1;
  }

  fprintf(stderr, "stdout successfully closed.\n");
  return 0;
}

...