Assigning an array to a FILE structure
Tom Rombouts
tomr at ashtate
Thu Oct 11 11:05:27 AEST 1990
They say the only stupid question is the one that isn't asked, so:
Is it possible using the ANSI stream I/O functions to assign an
array to a FILE structure so that fgetc() etc. will work on it?
To wit, I want to create code like this:
FILE * input_source;
char mybuffer[] = "This is text that I sometimes want to parse";
if( read_input_from_disk )
input_source = fopen("somefile", "rb");
else
input_source = make_virtual_file( mybuffer, strlen(mybuffer) );
ch = fgetc( input_source );
After RTFM'ing, it seems like this might be possible. Perhaps one
can explicitly assign the FILE structure members. Or, maybe there is
a way to attach the buffer to stdaux or stdin. (If it matters I am
using MSC 5.1 in MS-DOS, but want to stay portable if I can.) This
would seem like a common trick. Netland, I seek your guidance....
Tom Rombouts Torrance Techie tomr at ashtate.A-T.com V:(213) 538-7108
More information about the Comp.lang.c
mailing list