1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char **argv) { int i, secs; if (argc != 2) { fprintf(stderr, "Usage: %s <n>\n", argv[0]); exit(0); } secs = atoi(argv[1]); for (i=0; i < secs; i++) { printf("%d\n", i); fflush(stdout); sleep(1); } exit(0); }