Advertisement
mvaganov

indexOf in C++

Dec 17th, 2014
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1.  
  2. // linear search
  3. int indexOf(const char needle, const char* haystack, int haystackSize, int startSearch) {
  4.     for(int i = startSearch; i < haystackSize; i++) {
  5.         if(haystack[i] == needle)
  6.             return i;
  7.     }
  8.     return -1;
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement