c++ 实现strcpy(),strlen()

时间:2014-10-01 18:55:41   收藏:0   阅读:197
char* strcpy(char *strDest,const char *strSrc)
{
    char *result=strDest;

    assert((strDest!=NULL)&&(strSrc!=NULL));
    while((*strDest++=*strSrc++)!=‘\0‘);
    
    return result;
}

int strlen(const char *str)
{
    int count=0;

    assert(str!=NULL);
    while(*str++!=‘\0‘)
        count++;

    return count;
}
 

 

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!