#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int substr(char dst[], char src[], int start, int len) { //从src的第start位开始往后数len个字符
int i;
for (i = 0; i < len; i++) {
dst[i] = src[start + i];
}
dst[i] = ‘\0’;
return i;
}
int main() {
char dst[] = { 0 };
char src[] = “abcdefg”;
int start = 2;
int len = 3;
int m;
m=substr(dst, src, start, len);
printf("%s\n", dst);
system(“pause”);
return 0;
}
从一个字符串中提取一个子字符串
最新推荐文章于 2022-04-10 16:45:23 发布