SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int index_of(char* hay, char* needle, size_t start) {
  2.   size_t len = strlen(hay);
  3.   size_t needle_len = strlen(needle);
  4.   int subfind = 0;
  5.   for (int j = start; j < len; ++j)
  6.   {
  7.     if (hay[j] == needle[0]) {
  8.       subfind = 1;
  9.       for (int k = 1; k < needle_len; ++k)
  10.       {
  11.         if (hay[j + k] != needle[k]) {
  12.           subfind = 0;
  13.           break;
  14.         } else {
  15.           subfind = 1;
  16.         }
  17.       }
  18.       if (subfind) return j;
  19.     }
  20.   }
  21.   return -1;
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top