#include struct count_to_n_data; struct count_to_n_data { int n; int c; }; int count_to_three(int pc); int count_to_n(int pc, void *data); int main(void); int count_to_three(int pc) { switch(pc) { case 0: printf("1\n"); return 1; case 1: printf("2\n"); return 2; case 2: printf("3\n"); return 3; case 3: ; } return -1; } int count_to_n(int pc, void *data) { count_to_n_data *d = (count_to_n_data *)data; switch(pc) { case 0: d->c = 1; while(d->c <= d->n) { printf("%d\n", d->c); ++ (d->c); return 1; case 1: ; } } return -1; } int main(void) { count_to_n_data d1, d2; d1.n = 10; d2.n = 15; int pc1 = 0; int pc2 = 0; while(pc1 != -1 || pc2 != -1) { if(pc1 != -1) { pc1 = count_to_n(pc1, &d1); } if(pc2 != -1) { pc2 = count_to_n(pc2, &d2); } } return 0; }