自行编写strcpy()函数

#include "stdafx.h"
#include <string.h>
#include <assert.h>
//using namespace std;


char* strcpy(char* strDest,char* strSrc){
	assert((strDest!=NULL) && (strSrc!=NULL));
	if(strDest==strSrc) return strDest;
	char * address = strDest;
	while((*strDest++ = *strSrc++)!='\0');
	return address;
}


int main(int argc, char** argv)
{	
	char s[] = "safe";
	char *t = new char;
	strcpy(t,s);
	printf("%s\n",t);
	return 0;
}

你可能感兴趣的:(C++,String,strcpy)