strcpy实现
Posted strive-sun
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了strcpy实现相关的知识,希望对你有一定的参考价值。
#include <iostream> #include <stdio.h> using namespace std; char *_strcpy(char* des, char* src) { if (des == NULL || src == NULL) { return 0; } // cout << (void*)des << endl; // cout << src << endl; // cout << *des << endl; // cout << *src << endl; int ret = 0; char* temp1 = des; char* temp2 = src; while (!(ret=*temp1 -*temp2) && *temp1) { temp1++; temp2++; } if (ret == 0) { return 0; } char* pIter = des; while ((*pIter++ = *src++) != ‘