4
I am trying to redo the strstr function (look for a value passed by parameter in a text, find shows the rest) by account.
This is my current code, it has already worked but I gave some miss click and stopped working for some reason.
I believe you are making some wrong statement on the pointers/array
follows the code
/* strstr.c */
#include <stdio.h>
#include <string.h>
char *ft_strstr(char *str, char *to_find)
{
int index;
int aux2;
char *aux3;
index = 0;
aux2 = 0;
aux3 = 0;
while (str[index] != '\0')
{
if (to_find[aux2] == str[index]) {
aux3[aux2] = str[index];
aux2++;
index++;
if (to_find[aux2] == '\0')
{
while (str[index] != '\0')
{
aux3[aux2] = str[index];
aux2++;
index++;
if (str[index] == '\0')
{
return aux3;
}
}
}
}
index++;
}
return (0);
}
int main(void)
{
/* char *psResultado;
char sFrase[] = "isto e um teste";
printf("\nEndereço Inicial = %s", sFrase );
A função retornará o endereço correspondente à localização do "to"
psResultado = strstr(sFrase, "vasc");
printf("\nEndereço inicial para a pesquisa = %s\n", psResultado );
printf("\nEndereço inicial para a pesquisa = %s\n", psResultado );
*/
printf("%s",ft_strstr("Testando","st"));
return 0;
}