#include "stdafx.h"
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
char * strcpytemp(char *to,const char *from){
if(to==NULL||from==NULL)
throw "Invalid arguments";
char *copy = to;
while((*to++=*from++)!='\0')
;
return copy;
}
int _tmain(int argc, _TCHAR* argv[])
{
char *from = "hello";
char *to=new char[strlen(from)+1];
to=strcpytemp(to,from);
cout<<to<<endl;
cout<<strlen(to)<<endl;
return 0;
}
|