#define _POSIX_C_SOURCE 1 #include #include int main(int argc, char *argv[]) { unsigned int borne; unsigned long n = 2; FILE *entree = fdopen(atoi(argv[1]), "r"); FILE *sortie = fdopen(atoi(argv[2]), "w"); if (entree == NULL || sortie == NULL) { perror(NULL); exit(EXIT_FAILURE); } printf("Borne: "); scanf("%u", &borne); fprintf(sortie, "%d %d ", 0, 1); fflush(sortie); for (;;) { fscanf(entree, "%lu", &n); if (n >= borne) break; printf("%lu ", n); fprintf(sortie, "%lu ", n); fflush(sortie); } printf("\n"); return EXIT_SUCCESS; }