void strcpy( char *strDest, char *strSrc ) { while( (*strDest++ = * strSrc++) != ‘\0’ ); }4分
void strcpy( char *strDest, const char *strSrc ) //将源字符串加const,表明其为输入参数,加2分 { while( (*strDest++ = * strSrc++) != ‘\0’ ); }7分
void strcpy(char *strDest, const char *strSrc) { //对源地址和目的地址加非0断言,加3分 assert( (strDest != NULL) && (strSrc != NULL) ); while( (*strDest++ = * strSrc++) != ‘\0’ ); }10分
char * strcpy( char *strDest, const char *strSrc ) { assert( (strDest != NULL) && (strSrc != NULL) ); char *address = strDest; while( (*strDest++ = * strSrc++) != ‘\0’ ); return address; }
http://blog.csdn.net/gpengtao/article/details/7464061/ 考虑内存重叠的情况
char *strcpy(char* strDest,char* strSrc)
{ASSERT(NULL != strDest&&NULL != strSrc);
char* strAddress = strDest;
while((*strDest++ = *strSrc++) != '\0');
return strAddress;
}
const char* strcpy1(char* dst, const char* src); const char* strcpy1(char* dst, const char* src) // 返回const char* { assert((dst != nullptr) && (src != NULL)); const char* tmp = src; // 必须是const char* while ((*dst++ = *src++) != '\0') {}; return tmp; } 和前面的区别是 const char* tmp = src;