Caracteres accentués

sprere16 Messages postés 13 Date d'inscription samedi 8 mai 2004 Statut Membre Dernière intervention 20 décembre 2006 - 9 avril 2006 à 02:26
BunoCS Messages postés 15476 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 3 mai 2024 - 10 avril 2006 à 10:09
slt,
voila mon prob, je voudrai Convertir une chaine de caracteres en une autre non accentués, mais a chaque fois mon code il me donne la meme erreur.
voici mon code :

#include
char* accent(char str[]){
for (int index= 0; str[index] != '\0'; index++){
if(str[index] == 'à' || str[index] == 'â' || str[index] == 'ä' || str[index] == 'Â' || str[index] == 'Ä'){
str[index] = 'a';
}
if(str[index] == 'é' || str[index] == 'è' || str[index] == 'ê' || str[index] == 'ë' || str[index] == 'Ê' || str[index] == 'Ë'){
str[index] = 'e';
}
if(str[index] == 'î' || str[index] == 'ï' || str[index] == 'Î' || str[index] == 'Ï'){
str[index] = 'i';
}
if(str[index] == 'ô' || str[index] == 'ö' || str[index] == Ô' || str[index] == 'Ö'){
str[index] = 'o';
}
if(str[index] == 'ù' || str[index] == 'û' || str[index] == 'ü' || str[index] == 'Û' || str[index] == 'Ü'){
str[index] = 'u';
}
if(str[index] == 'ç'){
str[index] = 'c';
}
if(str[index] == 'ñ' || str[index] == 'Ñ'){
str[index] = 'n';
}
}
return str;
}
int main(void){
char* t = "salut éàèùôËÂ";
t = accent(t);
printf("%s\n",t);
return 1;
}

l'erreur est ---->> constante caractère multi-caractère
comparison is always false due to limited range of data byte

pls c urgent et j'en ai vraimant trop trop besoin!!!

Skalli

3 réponses

cs_Joky Messages postés 1787 Date d'inscription lundi 22 novembre 2004 Statut Membre Dernière intervention 31 janvier 2009 2
9 avril 2006 à 02:45
essai de bien parenthésé tes if ou bien fait un switch c'est bien plus pratique

if(!Meilleur("Joky")) return ERREUR;<
0
platon179 Messages postés 237 Date d'inscription lundi 20 mai 2002 Statut Membre Dernière intervention 22 juillet 2011 2
9 avril 2006 à 08:59
Salut :)

if(str[index] == 'ô' || str[index] == 'ö' || str[index] == Ô' || str[index] == 'Ö'){
str[index] = 'o';
}

Il te manque une simple quote avant Ô...
Et par pitié passe au switch :)
@+
0
BunoCS Messages postés 15476 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 3 mai 2024 103
10 avril 2006 à 10:09
Sinon, tu peux mettre 2 tableaux en correspondance... J'ai pas testé mais ça donne a priori un truc du genre:

char * accent(char * str)
{
char accent[] = "éèêëàâ...";
char simple[] = "eeeeaa...";
char * index;

for (int i=0; str[i]; i++)
{
index=strchr(accent,str[i]);
str[i]=*(simple+index);
}

return str;
}

Buno
----------------------------------------
L'urgent est fait, l'impossible est en cours. Pour les miracles, prévoir un délai...
Le site de mon mariage
0
Rejoignez-nous