Re: I was told this line of code would get me fired



Ralf Fassel <ralfixx@xxxxxx> writes:

* "Chad" <cdalten@xxxxxxxxx>
| I was told the follwing line of code:
|
| for(;fread(&log_file,sizeof(struct utmp),1,fp) !=0;)
|
| would have gotten me fired had I used this out in the workforce. Can
| someone clue me on what is going wrong here?

If the number of bytes read by fread() is less than the requested
number of bytes but greater than zero,

fread() will return 0.

the code will work on an incomplete utmp struct.

No, that's not the problem here.

--
Måns Rullgård
mru@xxxxxxxxxxxxx
.



Relevant Pages