I'll attempt to give a more hand wavey approach, but one that is hopefully easier to understand.
First, implement:
\\ find first index of `c` within string `str`.
\\ returns true if found, sets `out` to result.
\\ otherwise returns false.
bool find(char* str, size_t len, char c, size_t* out)
Now this can be used in a loop, where you supply a slice starting at the last line (or the beginning of the slice, on the first iteration), where len is the length of the original string minus the amount of characters consumed (index of the beginning of the slice, relative to the start of the original string).
Note this requires calculating the string length beforehand, if this is a c-string (as in null terminated).
This should be relatively simpler to understand and implement than what the standard library supplies, sadly the C standard library is not easy to use or very reliable, so you'll mostly have to make do yourself.
I hope this helped, I'm currently away from a computer so i can't give a code example, good luck.