截取若干个字符后面的字符串

#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

posted @ 2020-06-24 09:59  道微真理  阅读(276)  评论(0编辑  收藏  举报