Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!hacgate!ashtate!tomr From: tomr@ashtate (Tom Rombouts) Newsgroups: comp.lang.c Subject: Assigning an array to a FILE structure Keywords: file I/O, streams Message-ID: <1389@ashton.UUCP> Date: 11 Oct 90 01:05:27 GMT Organization: Ashton-Tate, Torrance, CA Lines: 27 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@ashtate.A-T.com V:(213) 538-7108