*** 自写代码:复制字符串

#include <iostream>
using namespace std;
char * strcpy1 (char * strDest, char * strSrc)
{
    if ((strDest==NULL) || (strSrc==NULL))
    {
        return NULL;
    }
    char * strDeskCpy = strDest;
    while ((*strDest++ = *strSrc++) != '\0');
    return strDeskCpy;
}
int main()
{
    char a[] = "abcde";
    char b[20] = "";
    strcpy1(b, a);
    cout << "b: " << b << endl;
    return 0;
}

 

posted @ 2018-12-23 19:11  super行者  阅读(206)  评论(0编辑  收藏  举报