Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucsdhub!hp-sdd!hplabs!hpda!hpcupt1!hpisod2!decot From: decot@hpisod2.HP.COM (Dave Decot) Newsgroups: comp.lang.misc Subject: Re: random i/o Message-ID: <13540005@hpisod2.HP.COM> Date: 29 Nov 89 23:09:33 GMT References: <111@lkbpyr.UUCP> Organization: Hewlett Packard, Cupertino Lines: 37 For BSD or HP-UX systems, here's select.c: #include #include main(argc, argv) int argc; char *argv[]; { char s[80]; struct timeval t; int i, j; gettimeofday(&t, 0); j = srand(t.tv_usec); freopen(argv[2], "r", stdin); gets(s); i = rand() % atoi(argv[1]) - 1; while(i-- > 0) gets(s); puts(s); } Usage: select `wc -l inputfile` inputfile For systems without gettimeofday() or some other rapidly changing value, you will have to find some other means of seeding the generator. Dave Decot Hewlett-Packard Company