Re: Treating a character string array pointer as a stream

From: Abigail Brady (morwen@evilmagic.org)
Date: 12/02/02


On Mon, 2002-12-02 at 23:01, Tseran wrote:
> What I want to do is treat the
> description pointer as a file stream and therefore be able to use the
> get_line() and fread_string() functions.  Is this possible, or would I
> have to re-write those functions to get that capability.  Any help
> would be appreciated, as this is something I have never even tried to
> attempt before.

Depending on what platform exactly you are using, this may be possible.
With glibc, you can use the fmemopen() function like that, for example -

   char buffer[1024];
   FILE *f = fmemopen(buffer, 1024, "w");
   fprintf(f, "This is an %s.\n", "example");
   fclose(f);
   printf("%s", buffer);

will print "This is an example.\n"

This isn't portable and I don't know what the equivilants are on other
platforms, sorry.

--
Abigail Brady <morwen@evilmagic.org>

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT