I'm so confused about fread and fwrite. In lab 4 " Volume", how can I know the number of samples in the input wav file? i=I need to use fread(buffer , size , qty , file operator ). So how can I know the count of samples?

1 Answer 1


Assuming the size to fread is 1 char, aka 1 byte, the qty argument to fread is the number of bytes to read per sample. The program does not need to be told the number of samples needed. Each one is independently sampled in, acted upon, and written out.
The lab setup gives the sample size, aka the qty: Your program should then read the rest of the data from the WAV file, one 16-bit (2-byte) sample at a time.

  • Thanks so much for your answer. I got it.
    – Aya Othman
    Feb 27, 2021 at 12:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .