une fonction rechercher char *
bien le bonjour a vous
j'essay de faire une fonction qui recherche une sous chain sur une autre et voila mon debile algo qui ne marche pas
j'ai besoin de vos lumieres SVP
Code:
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
|
char *ZString::rechercher(char *str)
{
int i=0 , j=0 ;
int taille=longueur(str) ;
char *mot=new char[taille +1] ;
while(m_chaine[i] != '\0'){
while(str[j] != '\0'){
if(m_chaine[i] == str[j] && m_chaine[i+1]==str[j+1]){
mot[j]=str[j] ;
mot[j+1]=str[j+1] ;
if(j==taille)
j=0 ;
else
j++ ;
}
}
i++;
}
return mot;
} |
Merci