fread (and I think fwrote also), return a value, this value represents the size read (or written).....
YOu might like to retrieve these values and print them to see whether one of these functions is causing the unexpected behaviour
fread (and I think fwrote also), return a value, this value represents the size read (or written).....
YOu might like to retrieve these values and print them to see whether one of these functions is causing the unexpected behaviour
Sorry Deman, but you are wrong, fread and fwrite returns number of elements readed/writen..
Still, OP can multiply with sizeof one element and that way discover unexpected behaviour, if there is one..
Are you suggesting that number of elements does not constitute size (You'll notice units were never mentioned)?
It depandes on what is the size of the element user requested when he called fread or fwrite.If it is 1byte then you are correct,but if it is more bytes per element he will need to multiply returned value with size of single element readed/writen
Granted, to get the size in bytes, number of elements needs to be mulktiplied by number of bytes in an element. But number of elements is still size (3 metres is still 3 metres even if it is 300 centimetres as well).
While printing the size in bytes may also be useful, I think it may also be helpful to print the size in number of elements, after all, you should probably consider data in its' rawest form if you want to find such peculiarities.
I appreciate that the size returned by these functions is not the size in bytes, however, I never suggested that it was, and feel my suggestion was worthwhile nonetheless.... .
Granted, to get the size in bytes, number of elements needs to be mulktiplied by number of bytes in an element. But number of elements is still size (3 metres is still 3 metres even if it is 300 centimetres as well).
While printing the size in bytes may also be useful, I think it may also be helpful to print the size in number of elements, after all, you should probably consider data in its' rawest form if you want to find such peculiarities.
I appreciate that the size returned by these functions is not the size in bytes, however, I never suggested that it was, and feel my suggestion was worthwhile nonetheless.... .
Sorry.
I thought that you are trying to tell that those functions returns size in bytes.
Comment