class Solution { public: char *strStr(char *haystack, char *needle) { if (!*needle) return haystack; char *start = haystack; char *temp1 = haystack, *temp2 = needle; while (*start){ temp1 = start; temp2 = needle; while (*temp2 && temp1 && !(*temp2 - *temp1)) temp2++, temp1++; if (!*temp2) return start; start++; } return NULL; } };
原文:http://www.cnblogs.com/Kobe10/p/6366174.html