Hi, I am trying to write a function that locate the last occurence of a string without using string library. Also, i would like to use pointers but I am getting "Segmentation Fault" every time i run the program.
heres my function. Thanks in advance guys.
Code:int str_char(char c, char *str)
{
int i;
int last = 0;
char *strptr = str;
while (*strptr != '\0') {
if (strptr[i] == c)
last = i;
}
return last;
}