首页 > 其他 > 详细

strcpy实现

时间:2014-04-25 07:04:45      阅读:514      评论:0      收藏:0      [点我收藏+]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
using namespace std;
char *strcpy(char *strDest, const char *strSrc)
{
    if ( strDest == NULL || strSrc == NULL)
        return NULL ;
    if ( strDest == strSrc)
        return strDest ;
    char *tempptr = strDest ;
    while((*strDest++ = *strSrc++) != ‘\0‘);
    return tempptr ;
}
 
int main()
{
    char strA[20]="ABCDEFGHIJKLMNOPQRS";
    char* strB="how are you ?";
    int length=strlen(strcpy(strA,strB));
    //int lh=strlen(strncpy(strA,strB,sizeof(strA)));
    //printf("%s",strA);
    cout<<length<<endl;
    /*cout<<lh<<endl;*/
    //char a[30] = "string(1)";
    //char b[] = "string(2)";
    //printf("before strncpy() : %s\n", a);
    //printf("after strncpy() : %s\n", strncpy(a, b, 8));
    while(1);
    return 0;
}

  

strcpy实现,布布扣,bubuko.com

strcpy实现

原文:http://www.cnblogs.com/wuyuankun/p/3684718.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!