c++ 算法题

参考
https://blog.csdn.net/tqy19921202/article/details/80763564

实现strcpy

#include <iostream>
using namespace std;

char* MyStrCpy(char *pDest,const char *pSrc)
{
  if(nullptr == pDest || nullptr == pSrc)
  {
    return nullptr;
  }
  if(pDest == pSrc)
  {
    return pDest;
  }
  char *plter = pDest;
  while((*plter++=*pSrc++)!='\0');
  return pDest;
}

int main(int argc, char *argv[])
{
    char a[100] = "abcd";
    char b[100];
    *b = *MyStrCpy(b,a);
    cout << b;
}

猜你喜欢

转载自blog.csdn.net/sinat_33859977/article/details/114955297