Code:
void write_deletion(D_RECORD *record, FILE *outfile)
{
fputc(record->type,outfile);
fputc(record->code[0],outfile);
fputc(record->code[1],outfile);
fputc(record->code[2],outfile);
fputc(record->code[3],outfile);
fputc(record->code[4],outfile);
fputc('\n',outfile);
}
I want to check if there has been an error writing to the outfile stream, could I just add an if( ferror(outfile) ){...}, after the call to the above function, in the calling function? Checking for EOF from each of the fputc calls will look a little messy...
I need to take into account that the HD may have filed up etc, and alert the user that there was an error.
Also, if there is an error, what is a good way to print it?
perror(FILENAME_OF_OUTFILE); is ok?
Thanks in advance.