zoukankan      html  css  js  c++  java
  • C语言strcat()库函数的实现

    C语言strcat()库函数的实现

    #include<stdio.h>
    #include<string.h>
    void MyStrcat(char *dstStr, char *srcStr)
    {
        int a,b,i;
        a=strlen(dstStr);
        b=strlen(srcStr);
        for(i=0;i<b;i++)
        dstStr[a+i]=srcStr[i];
        dstStr[a+b]=0;
    }
    void main()
    {
        char dst[500];
        char src[200];
        printf("Input the first string:");
        gets(dst);
        printf("Input the second string:");
        gets(src);
        MyStrcat(dst,src);
        printf("The result is: %s
    ",dst);
    }

    思路:将dst后面的’/0’由src的第一个字符覆盖即可

    博客园:https://www.cnblogs.com/newtol 微信公众号:Newtol 【转发请务必保留原作者,否则保留追责权利】
  • 相关阅读:
    THINKPHP导入全部post参数
    thinkphp 表单一些
    随机唯一不重复
    TP关联模型
    PHP函数之类
    MSSQLid清零
    httpwebrequest异步参考
    反射
    UrlOper
    工作周记
  • 原文地址:https://www.cnblogs.com/newtol/p/10159141.html
Copyright © 2011-2022 走看看