To print a user-readable error message to stderr, call perror from <stdio.h>.
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;
}
r...