Skip to content
Extraits de code Groupes Projets
prime.c 684 octets
Newer Older
  • Learn to ignore specific revisions
  • //
    // Created by Louis Malevez on 18-04-20.
    //
    #include <stdio.h>
    #include <stdlib.h>
    #include "primeF.h"
    
    int main(int argc, char *argv[]) {
        printf("argv[1]: %s\n", argv[1]); // argv[1] = input file path
        printf("argv[2]: %s\n", argv[2]); // argv[2] = output file path
        FILE *f_in = fopen(argv[1], "r");
        FILE *f_out = fopen(argv[2], "w");
        if (f_in == NULL) exit(1);
        if (f_out == NULL) exit(1);
    
        int chiffre =0;
    
        while (fscanf(f_in, "%d", &chiffre) != EOF) {// parcours les entiers
            primeFactors(chiffre,f_out);// fonction qui écrit un entier et ses diviseurs premiers ds un fichier
    
        }
    
        fclose(f_in);
        fclose(f_out);
        return 0;
    }