args

导航

公告

Free Web Counter

文章

收藏

相册

其他

存档

Blog统计


正在读取评论……

#C/C++

从一个字符串中取出需要的子串

#include <assert.h>
#include <string.h>
/**
 * name: strFrom
 * desc: 根据起始位置从一个字符串中取出需要的子串
 *    
 */

char * strFrom (const char * strSource,int m, int n)
{
 assert(strSource!=NULL&&m+1<n&&m>=0);
 char * result=new char[n-m];
 char * address=result;
 for(int i=0; i<(int )strlen(strSource);i++){
     if(i<n && i>m)
          *result++=strSource[i];
 }
 *result='\0';
 return address;
}

发表于 @ 2005年05月23日 2:08 PM | 评论 (0)

第1页,共1页