It's UWAweek 48

help2002

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 919 articles.
Currently 4 other people reading this forum.


 UWA week 34 (2nd semester, week 5) ↓
SVG not supported

Login to reply

👍?
helpful
6:07am Fri 26th Aug, Christopher M.

"Cohen Rafiq" <23*4*9*[email protected]*u*e*t*u*a*e*u*a*> wrote:
> When reading a file I have seen some places check for an EOF byte and some check for NULL byte. Are these the same thing and if not, what are the differences and which is preferred to use?
Neither EOF or NULL are actual *bytes* that are read from a file - if you think about it, any program could write the byte with value -1 (EOF) or 0 (NULL) into a file and follow it by more data, but that byte doesn't signify the end-of-file. Instead, EOF and NULL are both just symbolic values returned by functions to signify that the end-of-file *condition* has been met/reached. As to which is the preferred one to use - you use the one that is returned by the function you're using to read from the file. Read the manual entries for both get() and fgets() and they explain their role in reporting that the end-of-file condition has been reached (in the section RETURN VALUE). In addition, there's a helpful function feof() which you can call at any time if you've "lost" the most recent return value.

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  1:17AM Sep 14 2022
Privacy policy