correcteur.c 980 Bytes
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

#define MAX_LETTRES 30


typedef struct node {
  char l;
  struct node * lettres[27];
  bool fin_de_mot;
  int dernier;
} Node;


void ajout(Node **N, char mot)
{
  Node *nouveau = malloc(sizeof(struct node));
  (*nouveau).l=mot;
  for (int i=0; i<27; i++) nouveau->lettres[i]=NULL;
  *N = nouveau;
}


void ajout_alphab(Node ** pn, char *  mot,int cpt)
{
  int i = 0;
  while (mot[cpt] != '\0'){
    while ((*pn)->lettres[i] != NULL){
      if (strcmp(&(*pn)->l,mot) != 0){
	i++;
      }
       *pn=(*pn)->lettres[i];
       return ajout_alphab(pn,mot,cpt++);
    }
    ajout(&(*pn)->lettres[i],mot[cpt]);
    *pn=(*pn)->lettres[i];
    cpt++;
  }
}


Node * charger_arbre(Node ** Arbre){
  FILE * dico;
  char mot[MAX_LETTRES];
  dico = fopen("words.txt","r");
  while (fscanf(dico,"%s",mot) == 1){
    ajout_alphab(Arbre,mot,0);
  }
  fclose(dico);
  return *Arbre;
}


int main(){
  return 0;
}