int charContainsToChar(char* source, char* target)//source是主串,target是子串 { int i, j; int s_len = strlen(source); int t_len = strlen(target); if (t_len>s_len) { return -1; } for (i = 0; i <= s_len - t_len; i++) { j = 0; int flag = 1; if (source[i] == target[j]) { int k, p = i; for (k = 0; k<t_len; k++) { if (source[p] == target[j]) { p++; j++; continue; } else { flag = 0; break; } } } else { continue; } if (flag == 1) { return i; } } return -1; }