File pointer to a memory location?
Steve Watt
steve at wattres.UUCP
Tue Sep 11 15:22:33 AEST 1990
In article <119609 at linus.mitre.org> rtidd at ccels3.mitre.org (Randy Tidd) writes:
>With all these new comp.unix.* groups coming out, I hope it's
>appropriate to cross-post to .programmer and .internals...
I'm not actually sure which is right, either. .programmer is probably closer.
>Anyhow, in the application i'm working on I have a series of routines
>that were written by someone else that do image processing (the fbm
[ slurp! ]
[ he doesn't have a file, but just a large block of RAM ]
>Can anyone help me out?
I just hacked this little piece of code together, you might find it amenable
to your application: Just set f._cnt to the size of the image block.
NOTE: This is terribly dependent on stdio being implemented in the
"standard unix" way... Or at least how it looks on my SCO box and my
DECStation.
----- ugh.c -----
#include <stdio.h>
char *buf = "This is a test of the emergency broadcast system. In the event\
of a real emergency, you would never have heard this signal. Seriously.\n";
main() {
FILE f;
int c;
f._cnt = strlen(buf);
f._ptr = f._base = buf;
f._flag = _IOEOF;
f._file = 0;
while ((c = getc(&f)) != EOF) {
putchar(c);
fflush(stdout);
}
}
----- end -----
Note also that you could just as easily have passed &f to some other function.
--
Steve Watt
...!claris!wattres!steve wattres!steve at claris.com also works
Don't let your schooling get in the way of your education.
More information about the Comp.unix.programmer
mailing list