Re: fseek and open_memstream
- From: rlb@xxxxxxxxxxxxxxxxxxxxxx (Richard Bos)
- Date: Wed, 31 Jan 2007 17:11:02 GMT
Dmitry Belous <dmitry_belous@xxxxx> wrote:
Why when I uncomment fseek line buf become empty?
#define _GNU_SOURCE
#include <stdio.h>
int main() {
char *buf = 0;
int size = 0;
FILE* f = open_memstream(&buf, &size);
fwrite("test", 1, 4, f);
// fseek(f, 0, SEEK_SET);
fclose(f);
fprintf(stderr, buf);
}
open_memstream() is not an ISO C function. It, or its return value,
probably interacts with fseek() in a way that clears buf, but _why_ this
happens is off-topic here. If it's a POSIX function (I don't know, your
compiler should tell you), ask in comp.unix.programmer. If it's not,
find a newsgroup that deals with your implementation - from the looks of
it, that's gcc, so ask gnu.help.something.
Richard
.
- References:
- fseek and open_memstream
- From: Dmitry Belous
- fseek and open_memstream
- Prev by Date: fseek and open_memstream
- Next by Date: Re: Initialising Variables
- Previous by thread: fseek and open_memstream
- Next by thread: Re: fseek and open_memstream
- Index(es):
Relevant Pages
|