#include <cstdlib> #include <iostream> #include <cstring> using namespace std; char *_strcpy(char *strDest, const char *strSrc) { assert(strDest != NULL && strSrc != NULL); const char *ptrSrc = strSrc; char *ptrDest = strDest; while(ptrSrc != NULL && *ptrSrc != '/0') *ptrDest++ = *ptrSrc++; *ptrDest = '/0'; return strDest; } int main(int argc, char *argv[]) { char *strSrc = "test string"; char *strDest = new char[strlen(strSrc) + 1]; _strcpy(strDest, strSrc); cout << strDest << endl; system("PAUSE"); return EXIT_SUCCESS; }