Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utcsstat.UUCP Path: utzoo!utcsrgv!utcsstat!physics From: physics@utcsstat.UUCP Newsgroups: net.lang.c Subject: Why does Kernighan pg 106 work? Message-ID: <836@utcsstat.UUCP> Date: Tue, 9-Aug-83 14:54:34 EDT Article-I.D.: utcsstat.836 Posted: Tue Aug 9 14:54:34 1983 Date-Received: Tue, 9-Aug-83 16:45:46 EDT Organization: U. of Toronto, Canada Lines: 44 Here is a fragment of code based directly on p.106,107 of Kernighan & Ritchie: #define SIZE 30000 #define BLOCKS 15000 main() { char *blkptr[LINES]; /* Pointer to blocks of text, see f1 */ if((n = f1(blkptr)) >= 0){ m =f2(blkptr,n); writestrings(blkptr,m); } } f1(blkptr) char *blkptr[]; { char s[SIZE]; /* Here is where the text is */ blkptr[0] = s; while((s[i++] = getchar()) != EOF && i < (SIZE-1))) ; s[i++] = '\0'; return(i); } f2(blkptr,n) char *blkptr[]; { for(i=0, i