#include <stdio.h>
#include <string.h>
char *strOp(char *oldstr, char newstr[])
{
int nsplash, i;
int res = 0;
nsplash=0;
for(i = 0; nsplash < 4 && oldstr[i]!= ‘\0‘;i++)
{
if(oldstr[i] == ‘/‘)
nsplash++;
}
for(;oldstr[i] != ‘\0‘;i++)
{
newstr[res++] = oldstr[i];
}
return newstr;
}
int main()
{
char s[] = "/sdb/data/1/20201212992.mp4";
char b[255] = {0};
char c[255] = "/mnt/usb33/download/";
strOp(s,b);
strcat(c,b);
printf("%s\n",b);
printf("%s\n",c);
return 0;
}
输出:20201212992.MP4
原文:https://www.cnblogs.com/fangzheng-nie/p/13186035.html