PERROR

要將使用者可讀的錯誤訊息列印到 stderr,請從<stdio.h>呼叫 perror

int main(int argc, char *argv[])
{
   FILE *fout;

   if ((fout = fopen(argv[1], "w")) == NULL) {
      perror("fopen: Could not open file for writing");
      return EXIT_FAILURE;
   }
return EXIT_SUCCESS;
}

這將列印有關 errno 當前值的錯誤訊息。