1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| #include <cstdlib>
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
int main(int argc, char *argv[])
{
//Variable
FILE *file = NULL;
FILE *file_clean = NULL;
char ligne[256];
int suppr=0;
char nom_clean;
//Ouverture du fichier choisi
file=fopen(argv[1],"r");
if (file == NULL)
{
printf("[INFO]Echec de l'ouverture de %s\n\n",argv[1]);
system("PAUSE");
return 0;
}
//creation du fichier clean
file_clean=fopen("Dico_cleaned.txt","w+");
if (file_clean == NULL)
{
printf("[INFO]Echec de la creation de Dico_cleaned\n\n");
system("PAUSE");
return 0;
}
while (fgets(ligne,256,file) != NULL)
{
for ( int i=0;i<26;i++)
{
suppr = 0;
for ( int j=0;j<26;j++)
{
if (ligne[i]==ligne[j])
{
suppr = suppr+1;
}
}
if (suppr < 6)
{
fprintf(file_clean,"%s",ligne);
printf("%s",ligne);
}
}
}
fclose(file_clean);
fclose(file);
system("PAUSE");
return EXIT_SUCCESS;
} |
Partager