Soundex.c 1.19 KB
#include <stdio.h>

void LireChar(char* pc){
    scanf("%c", pc);
}

int EstCarac(char n){
    int res;
    if ((n >= 'A' && n <= 'Z')||(n >= 'a' && n <= 'z' )){
         res = 1;
    }
    else{
         res = 0;
    }
    return(res);
}

int EstVoyelle(char n){
    int res;
    if (n == 'a' || n == 'e' || n == 'i' || n == 'o' || n == 'u' || n == 'y' || n == 'A' || n == 'E' || n == 'I' || n == 'O' ||n == 'U' ||n == 'Y'){
          res = 1;
    }
    else{
          res = 0;
    }
    return(res);
}


int main(){
    
    char c, stock;
    int j=0,resC, resV;
    printf("Saisissez votre nom : ");
    LireChar(&c);
    resC = EstCarac(c);
    
    if(resC == 1){
        printf("Code Soundex : %c",c);
        j= j+1;
        stock = c;
    }
        
    else {
        printf("Nom incorrect !");
    }
    
    
    while(j < 4 && resC != 0){
        
        LireChar(&c);
        resC = EstCarac(c);
        resV = EstVoyelle(c);
        
        if(resC == 1 && resV == 0 && c != stock){
            printf("%c", c);
            j=j+1;
            stock=c;
        }
    
    }
    printf("\n");
    return(0);
}