It's UWAweek 8


This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying selected article
Showing 1 of 1168 articles.
Currently 2 other people reading this forum.

 UWA week 35 (2nd semester, week 6) ↓
SVG not supported

Login to reply

5:03pm Mon 28th Aug, Christopher M.

"Minn Minn Khant Maw" <23*7*0*3@s*u*e*t*u*a*e*u*a*> wrote:
> # Graceful exits > > Should we include graceful exits in the program? For example I have this code snippet in my program for when the file does not exist. > > ''' > if (file == NULL) { > perror("Error opening file!!"); > exit(EXIT_FAILURE); > } > ''' > > The question is are we required to take these sorts of errors into account? Errors like non existent files, or wrong file types? Or can we *assume* that these sorts of problems wouldn't exist.
This is the sort of question where the best answer is "if you know what would make your program better, why not do it?". We know that the format of the input files is correct, and their data consistent, so most of those 'difficult' errors won't occur. And I encourage you to compile and run the following code:
    if(fopen("blahblah", "r") == NULL) {
        perror("Error opening file!!");

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  5:07AM Sep 06 2023
Privacy policy