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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
| #include <stdio.h>
#include <stdlib.h>
#define TAILLE_MAX 10000
//parcourt et affiche la grille
void parcoursGrille()
{
int i=0; int j=0;
char vC;
FILE* FICHIER=NULL;
FICHIER = fopen("grille.txt", "r+");
if (FICHIER!= NULL)
{
for(i=0;i<15;i++)
{
for(j=0;j<30;j++)
{
fscanf(FICHIER, "%c", &vC);
if (vC!='\n')
{
printf("%c", vC);
}
}
printf("\n");
}
fclose(FICHIER);
}
}
int LongueurFichier(char* nom)
{
FILE* fichier = NULL;
char chaine[TAILLE_MAX] = "";
long compte;
fichier = fopen(nom, "r");
compte =0;
if (fichier != NULL)
{
while (fgets(chaine, TAILLE_MAX, fichier) != NULL) // On lit le fichier tant qu'on ne reçoit pas d'erreur (NULL)
{
compte= compte +1;
}
fclose(fichier);
}
return compte;
}
void chargeDico(char* nom, char TabD[], int longD)
{
FILE* fichier = NULL;
char chaine[TAILLE_MAX] = "";
char* mot;
printf("%s\n",nom);
fichier = fopen(nom, "r");
if (fichier != NULL)
{
printf("%d\n",longD);
while ( fgets(chaine,TAILLE_MAX,fichier) != NULL)
{
strcpy(mot,chaine);
printf("chaine: %s\n",chaine);
printf("lecture: %s\n",mot);
system("PAUSE");
}
fclose(fichier);
}
}
/*
void chargeMot(char* nom, char TabM[], int longM)
{
FILE* fichier = NULL;
char chaine[TAILLE_MAX] = "";
int i=0;;
fichier = fopen(nom, "r");
if (fichier != NULL)
{
while (fgets(chaine, TAILLE_MAX, fichier) != NULL) // On lit le fichier tant qu'on ne reçoit pas d'erreur (NULL)
{
TabM[i]=chaine;
i++;
}
fclose(fichier);
}
}
void Recherche(char TabD[], int longD, char* TabM[], int longM, char TabR[])
{
int i=0; int j=0; int length=0; int z=1; int k=0; int compte=0;
char* lettre="";
for(i=0;i<=longD;i++)
{
//char mot[]= TabD[i];
for(j=0; j<=longM; j++)
{
for(k=0;k<= strlen(TabD[i]);k++)
{
strncpy(&lettre, &TabD[i], 5);
printf("ici :%c",lettre);
if(lettre==TabM[j])
{
compte++;
}
}
if(compte== strlen(TabD[i]))
{
TabR[z]=TabD[i];
z++;
}
}
}
}
*/
int main(int argc, char *argv[])
{
int longD; int longM;
parcoursGrille();
system("PAUSE");
longD = LongueurFichier("dico.txt");
longM = LongueurFichier("mot.txt");
char TabD[longD];
//char TabM[longM];
//char TabR[longD];
//chargeDico("dico.txt", TabD, longD);
FILE* fichier = NULL;
char chaine[TAILLE_MAX] = "";
char* mot;
long i=1;
fichier = fopen("dico.txt", "r");
if (fichier != NULL)
{
printf("%d\n",longD);
while (fgets(chaine, TAILLE_MAX, fichier) != NULL)
{
strcpy(mot,chaine);
TabD[i]=mot;
i++;
system("PAUSE");
}
fclose(fichier);
}
//chargeMot(mot, TabM, longM);
//Recherche(TabD, longD, TabM, longM, TabR);
system("PAUSE");
return 0;
} |