/* Course Number : ISYS 116 Student Name : Jason Gradziel Student Number : 826-135-535 Professors Name : Gene Rychlewski Class Name : Thursday Lab Title : */ #include #include #include FILE * Safe_fopen(char *f_name, char *mode) { FILE *file_ptr; if ( (file_ptr = fopen(f_name, mode)) == NULL) { fprintf(stderr, "\nError: File %s cannot be opened.", f_name); getch(); exit(1); } return file_ptr; } //FILE *Safe_fopen(char *, char *); void Safe_fclose(FILE *file_ptr) { if ( fclose(file_ptr) == EOF) { fprintf(stderr, "\nError: The file cannot be closed."); getch(); exit(1); } return; } //void Safe_fclose(FILE *); main() { clrscr(); FILE *input_file, *output_file, *printer_file; int ch=0; char file_name[51]; char che[21]; printf("\nEnter the name of the file you want to open: "); gets(file_name); input_file = Safe_fopen(file_name, "r"); output_file = Safe_fopen("dblspace", "w"); printer_file = Safe_fopen("prn", "w"); printf("\nThe file(s) was succfully opened."); //getch(); //fflush(stdin); //fflush(stdout); while ( (ch = fgetc(input_file)) != EOF ) { fputc(ch, output_file); fputc(ch, printer_file); //getch(); if (ch == '\n') { putc('\n', output_file); putc('\n', printer_file); } } Safe_fclose(input_file); Safe_fclose(output_file); Safe_fclose(printer_file); printf("\nThe file(s) was closed succfully."); getch(); return 0; }