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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main()
{
char str[10000],c='a';
int imot=0,jlettre=0, count=0;
FILE *fp;
fp=fopen("hauts.txt","r");
/* printf("Entrer une chaine de caractere: ");
gets(str);*/
while (!feof(fp)){
c=fgetc(fp);
if(c== ' ' || c== '\t' || c== '\n') count++;
else printf("%c",c);
}
printf("\n il y a %d mots\n",count);
char tabmots[count][30];
printf("%d\n",sizeof(tabmots));
fp=freopen("hauts.txt","r",fp);
while (!feof(fp)){
c=fgetc(fp);
if((c<65) || (c>90) || (c<97) || (c>122)) {
//printf("%s\n",tabmots[imot]);
imot++;
jlettre=0;
}
else {
tabmots[imot][jlettre++]=c;
printf("%d \t %c ",c,c);
}
}
/* for(i = 0; str[i] != '\0'; i++) //compter nombre total mot dans le texte
{
if(str[i] == ' ' || str[i] == '\t' || str[i] == '\n')
{
count++;
}
}
printf("il y a %d mots\n",count);*/
fclose(fp);
/* int tableau_mot[count], tableau_nombre_utilisation[count];
for (...)
{
if (mot existe pas encore)
{
ajoute au tableau
ajoute +1 a tableau_nombre_utilisation
}
else (mot existe deja)
{
cherche dans le tableau ou est le mot
recuperer le numero de la case
fait +1 dans l'autre tableau (tableau_nombre_utilisation) au bon numero de case
}
}
for (i=0; i<count; i++)
{
printf("\nle mot %c est apparu %d fois", tableau_mot[i], tableau_nombre_utilisation[i]); //affchage resultat (nombre de mot different total)
}*/
return 0;
} |
Partager