#include#include #include #include int substr(char dst[], char src[], int start, int len){ assert(src != NULL && dst != NULL); char *pdst = dst; int lensrc = 0; while (start--) { src++; } lensrc = strlen(src); if (lensrc < len) { len = lensrc; } while (len--) { *dst++ = *src++; } *dst = '\0'; return strlen(pdst);}int main(){ char s[] = "abcdefg"; char str[20]; int ret = substr(str, s, 4, 5); printf("%s\n", str); printf("%d\n", ret); system("pause"); return 0;}