0

Hello every one I want to ask question about fread and fwrite function

i have called the fread function like this

 fread(&buf , sizeof(short int) ,1 ,f1);

and also like this

 fread(&buf , 1, sizeof(short int) ,f1);

similarly fwrite both are working correctly.why ? which is actually right ?and which to use? thanks

1 Answer 1

0

The first is correct. The second may result in reading just a partial short.

The second parameter is record size and the third is the number of records. fread will read an integer number of records, but may read fewer than the requested number of records (for instance, if EOF is encountered).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.