How do I do the in-place equivalent of strstr() for a counted string (i.e. not null-terminated) in C?
How do I do the in-place equivalent of strstr() for a counted string (i.e.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re afraid of O(m*n) behaviour – basically, you needn’t, such cases don’t occur naturally – here’s a KMP implementation I had lying around which I’ve modified to take the length of the haystack. Also a wrapper. If you want to do repeated searches, write your own and reuse the
bordersarray.No guarantees for bug-freeness, but it seems to still work.