tree.c 1.84 KB
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define size 50
#define taille 26

struct noeud { char valeur; struct noeud * fils[28]; int complet;};
struct dico {struct noeud* tableau[26];};
typedef struct noeud* Noeud;


void cons_noeud (Noeud * pN, char a)
{ 
    *pN = malloc(sizeof(struct noeud));
    (*pN)->valeur=a;
    (*pN)->complet=0;
    for(int i=0; i<28; i++)
    {
        (*pN)->fils[i]=NULL;
    }
}

void ajout_noeud_dico(struct dico * D, Noeud N)
{
    int i=0;
    while(D->tableau[i]!=NULL)
    {i++;}
    D->tableau[i]=N;
}

void ajout_mot(Noeud * pN, char mot[size])
{
    if(*pN==NULL)
    {
        cons_noeud(pN,mot[0]);
        sup_lettre(mot);
    }
    else
        
}

char * sup_lettre(char mot[size])
{
    for(int i=1; i<size; i++)
    {
       mot[i]= mot[i+1];
    }
    printf("%s\n",mot);
}

//Reprendre cette fonction! 

/*void cons_dico_file(FILE* fp, struct dico* D)
{ char mot[size];
  if(fp==NULL)
    return;
  while(fscanf(fp,"%s",a)==1)
    { ajout_mot(D,a);
    //D->dernier++;}
    
    }*/

/*int rech_mot(struct dico D,char mot [size])
{
    Noeud N;
    int nbre;
    for(int i=0;i<D.dernier;i++)
      {
	if(D.tableau[i].valeur==mot[0])
	  {
	     N=D.tableau[i];
	    for(int j=0;j<size;j++)
	      {
		if(N.valeur==mot[j])
		  N=*(N.fils)->noeud;
		else
		  nbre=0;
	      }
	    if(N.complet==1)return newmot
	      nbre=1;
	  } 
	else
	  nbre= 0;
      }
    return nbre;
    }*/


/*void correction_texte(char filename[size], struct dico D)
{
  FILE *fp=fopen(filename, "r");
  char mot[size];
  int x;
  if(fp==NULL)return newmot
    return;
  else
    {
      while(fscanf(fp,"%s",mot)==1)
	{
	  x=rech_mot(D,mot);
	  if(x==0)
	    {
	      printf("il y a une erreur!\n");
	      printf("%s",mot);
	    }
	}
    }
	  
  
    }*/

int main()
{
    char* newmot;
    sup_lettre("emilie");
    
    return 0;
}