/* * seq: dump a sequence of to stdout, one per line. * idea by Kernighan & Pike, in _The UNIX Programming Environment_, * filtered through Copeland & Haemer, in _Server/Workstation * Expert_ (Vol 11 #2) as a perl program. * * Public domain, written by orc@pell.chi.il.us (jessica l. parsons), who would * like to receive millions of dollars every time this code is used, but, * hey!, it's completely free. */ #include #include char *pgm; void seq(char *low, char *high) { /* A clever implementation of this would do sequencing of non-numeric * arguments. But that would take time and energy to do. */ unsigned long lownum = atoi(low); unsigned long highnum = atoi(high); while (lownum <= highnum) printf("%ld\n", lownum++); } void main(int argc, char **argv) { char *p; pgm = basename(argv[0]); if (argc < 2 || argc > 3) { fprintf(stderr, "usage: %s range\n" " %s low high\n", pgm, pgm); exit(1); } switch (argc) { case 2: seq("1",argv[1]); break; case 3: seq(argv[1], argv[2]); break; } exit (0); }