string - Check for a substring in C++ -


this added functionality need build existing library. trying to check if string contains substring. have pointers start , one-past-the-end of main string,(which substring of larger string) , word search string datatype.

char * start; char * end; string wordtosearchfor 

i read find in c++, having trouble figuring out how work pointer inputs. there inbuilt function works inputs in form? or efficient read start end new string can used find?

thanks!

first of can indeed use member function find of class std::string. example

char * start; char * end; std::string wordtosearch;  // setting values variables  std::string::size_type n = wordtosearch.find( start, 0, end - start ); 

also there standard algorithm std::search declared in header <algorithm> example

char * start; char * end; std::string wordtosearch;  // setting values variables  std::string::iterator = std::search( wordtosearch.begin(), wordtosearch.end(),                                          start, end ); 

in these examples suppose end points after last character of seached substring.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -