Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!gatech!bloom-beacon!think!ames!ptsfa!hoptoad!academ!killer!jfh From: jfh@killer.UUCP (John Haugh) Newsgroups: comp.lang.c Subject: Re: stream sampler needed Message-ID: <1134@killer.UUCP> Date: Tue, 14-Jul-87 18:41:53 EDT Article-I.D.: killer.1134 Posted: Tue Jul 14 18:41:53 1987 Date-Received: Sun, 19-Jul-87 06:45:19 EDT References: <8233@brl-adm.ARPA> Organization: The Unix(tm) Connection, Dallas, Texas Lines: 33 Summary: I hope it's not April Fool's Day In article <8233@brl-adm.ARPA>, MISS026%ECNCDC.BITNET@wiscvm.wisc.EDU (GREENY) writes: > Hi all... > > I was wondering if anyone had any source code to sample a continous > stream of data, throwing away (/dev/null) what wasnt sampled. Basically > i have a continous stream of data and I would like to wait until I > get a specific character, and then capture the next 13 characters. This is too easy - but into the mire I fall ... -------------------------- cut somewheres near here ----------------- /* * Does the above requested task with no error checking */ sample (fp, c, n, s) FILE *fp; /* input stream */ char c; /* character to look for */ int n; /* number of characters to copy after `c' */ char *s; /* where to put them */ { int in; while ((in = getc (fp)) != c) ; while (n-- > 0) *s++ = getc (fp); } This had better not be a joke ... - john.