I'm getting this error:
Warning: assignment makes integer from pointer without a cast [enabled by default]
This is my source code:
int ft_replace(char const *s1)
{
int result;
result = 0;
for (; *s1 != '\0'; ++s1)
{
if (*s1 == '-')
result = s1; // Warning here
}
return (result);
}
So, I'm getting an error ( warning ) and my result of my function ft_replace is fxc...
It return me a result like 4227111 and I don't know why
I would like my function when it find the last char here this is ' - ' it return the position of the array.
So a string which contains " Hel-l-o " -> Return 6
A string which contains " He-llo " -> Return 3
A string which contains " Hell-o- " -> Return 7
s1is pointer, not a number(index). You can use additional counter, to count the index/position, or use pointer arithmetic to calculate the position.int ft_replace(char const *s1) { int result; result = 0; for (const char* s = s1; *s != '\0'; ++s) { if (*s == '-') result = (s1-s); } return (result); }