char* substr(const char*str,unsigned start, unsigned end)
{
unsigned n = end – start;
static char stbuf[256];
strncpy(stbuf, str + start, n);
stbuf[n] = 0;
return stbuf;
}
c中strncpy也可以实现这个功能
char *strncpy(char *dest, char *src, int n);
strncpy( strtemp,str+n , m )
–strtemp字符串变量,截取后的字符串存放处
–str 字符串变量,要截取的字符串
–n ,int 型,
— str+n, 表示从第n 位开始截取字符串
–m,int型,表示截取m位
转自: http://blog.csdn.net/lihuixue_amy/article/details/
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/201287.html原文链接:https://javaforall.net
