Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. char *myStrStr(const char *s1, const char *s2) {
  2. if (!*s2) return NULL;
  3. char *p1 = (char*)s1;
  4. while (*p1) {
  5. char *p1Copy = p1;
  6. char *p2 = (char*)s2;
  7. while (*p1 && *p2 && *p1 == *p2) {
  8. p1++;
  9. p2++;
  10. }
  11. if (!*p2){
  12. return p1Copy;
  13. }
  14. p1 = p1Copy + 1;
  15. }
  16. return NULL;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement