I'm new to these wanderings, sorry if it's a stupid question. but can they enlighten me what what's doing there?
char *ft_strchr(char *s, int c)
{
int i;
i = 0;
if (!s)
return (0);
if (c == '\0')
return ((char *)&s[ft_strlen(s)]); // THIS LINE
while (s[i] != '\0')
{
if (s[i] == (char) c)
return ((char *)&s[i]); // THIS LINE
i++;
}
return (0);
}
I know this is being performed a cast to that variable but I had not yet come apart with this & there in the middle. and to test this function if I take it out of there... it crash.
Someone help me please???
the function is working properly it finds the first occurrence of c in the string and returns the pointer with its position. I just wanted to understand this application better.