字符串拼接

#include <iostream>
#include <cstring>
#include <cstdlib>

char *mystrcat(char *dst,const char *src) //用自己的方式实现strcat函数功能

  {
       char *p=dst;  //下面的操作会改变目的指针指向,先定义一个指针记录dst
       while(*p!='')p++;
       while(*src != '')*p++=*src++;
       *p='';
  return dst;  
  }
 
int main()
{
    using namespace std;
    char d[20] = "GoldenGlobal";
    char* s = "View";
    system("cls");
    mystrcat(d,s);
    cout << d << endl;
    system("pause");
    return 0;
}

 

原文地址:https://www.cnblogs.com/hongdoudou/p/13379135.html