I have been working through this problem and cannot figure out why this while loop is producing an infinite loop and no image files, which is probably caused by a logic error on my part. As far as I understand from the manpages, fread
should return 1
as long as it is a successful read of the given size
parameter and the read quantity is 1
. But, it should return zero as long it cannot read a full quantity of the given size
.
So, my understanding is that this while loop will continue to have a true condition only until it fread
can no longer read a full segment of 512 bytes into my buffer array. Clearly, though, there is some error that I cannot find because it does not break out of the loop nor produce any images.
I have gone through all of the relevant topics that I could find on here (and through a web search) regarding similar issues to mine with this problem. Most of these did not help, though, as they either did not have much/any code snippets to see to help understand the suggestion/answer or had other errors produce their problems (given that the solutions provided were already implemented in my code).
Hopefully this provides sufficient information for someone to help point me in the right direction. Thank you in advance.