You are not logged in. Please login at to post your questions!


Difference Between str.find() in C++ and matching algorithms like KMP etc. and strstr() in C ?

What Is The Difference Between This STL Function and These KMP Algorithms.. and also function strstr() in c

asked 13 Oct '15, 11:33

goyal_banna's gravatar image

accept rate: 8%

edited 26 Oct '15, 14:10

admin's gravatar image

0★admin ♦♦

In general the answer will be: It depends on the implementation. For the gnu compiler you can look it up for yourself in the source code of gcc or glibc. I had a short look at the glibc version of strstr. They seem to use the naive algorithm for short strings and some kind of improved version of KMP for linger strings. So in essence if you're just looking for a substring, there is no reason to implement something like KMP because the library version will be roughly as fast as yours.


answered 13 Oct '15, 20:38

ceilks's gravatar image

accept rate: 36%

Great stuff from you, Ive read your stuff before and you’re just too awesome. But I really enjoyed the article. buy cheap essays


answered 14 Oct '15, 12:50

skorniaalison's gravatar image

accept rate: 0%

Very interesting, I can ask about this, my friends. Moreover, I was really confused a little by it.But I can share with you a great topic, which helps me a lot. What do you do when you have no time left to complete or start your term paper? You can start your term paper here -


answered 23 Mar '16, 15:44

roark159's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 13 Oct '15, 11:33

question was seen: 2,995 times

last updated: 23 Mar '16, 15:44