I have a stream like so:
FILE *fp;
byte *buf;
size_t len;
fp = open_memstream(&buf, &len);
I write some bytes into it.
Now I want loop from the beginning of the stream to the end. I have a method that that does something like this
void method(FILE *fp)
{
while(!feof(fp)){
fread(Buffer, sizeof(byte), BUFSIZE, fp);
}
}
But the while loop never stops. I also explicity tried to write EOF char to fp but feof did not work. What's going on here?