0

I am heandling right now recover side by side by example of resize and copy.

I have some big problem that I do not understand with fread function:

here is the code:

//start the process
fread(infile, 1, 512, infile);

//read the file until we will reach not 512 byte puzzle
while (fread(infile, 1, 512, infile) == 512)

Does it work as I am 'doing' it? I think no but to be honest i tryed to read and read about it and I cannot get any idea - I have also watched code of other ppl and they do define the buffer but I am not able to wrap my head around that.

Can somebody help me with some advice?

1

I might not be the best to help but I can try.

I see when you call fread like this you are using infile 2 times in the arguments.

fread(infile, 1, 512, infile);

The first argument should be a array buffer of size 512. Check out the example here: https://reference.cs50.net/stdio/fread

Also here is how I have it in my implementation that passes check50.

char buffer[512];
while (fread(buffer, 512, 1, in) == 1)

You must log in to answer this question.

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