Recode strstr en C

Fermé
evolution - 10 oct. 2011 à 23:48
KX Messages postés 16733 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 31 janvier 2024 - 11 oct. 2011 à 13:03
Bonjour,
je dois recoder la fonction strstr en C, seulement j'ai un probleme (segmentation fault)
help,


char *my_strstr (char *str, char *to_find)
{
char *pointeur;
int i;
int j;
int counter;

pointeur = NULL;
i = 0;
j = 0;
counter = 0;
while (pointeur == NULL && str[i] != '\0')
{
if (str[i] == to_find[j])
{
while(str[j] == to_find[j])
{
j++;
if (to_find[j] == '\0')
*pointeur = to_find[i];
}
j = 0;
counter = i;
}
i++;
}
return (pointeur);
}





2 réponses

désolé pour l'indentation :/
0