我爱Aspx >> VC.Net >> 使用strcpy的几点心得使用strcpy的几点心得
sp; 根据《出现频率最高的笔试题》cphj(原作),及众多的网友的观点。本人做了以下总结:
大多数人都同意以下这个写法:只是个人风格有些不同而已。
char *strcpy(char* dest, const char* src)
{
assert(NULL != dest);
assert(NULL != src);
char *tmp = dest;
while(´\0´ != (*tmp++=*src++)) //因为*tmp不是布尔值所以有必要比较
;
return(dest);
}
而根据MS中的定义如下:
(%VC%/vc7/crt/src/intel/strcat.asm)
page
;***
;char *strcpy(dst, src) - copy one string over another
;
;Purpose:
; Copies the string src into the spot specified by
; dest; assumes enough room.
;
; Algorithm:
; char * strcpy (char * dst, char * src)
; {
; char * cp = dst;
;
; while( *cp++ = *src++ )
; ; /* Copy src over dst */
; return( dst );
; }
;
;Entry:
; char * dst - string over which "src" is to be copied
【我对这篇文章有话说?】
用MASK方法传送不规则位图[05-21]
vc调试经验[05-21]
Matt Austern : Defining Itera..[05-21]
C++深度探索系列:智能指针(Smar..[05-21]
Effective STL Item 43:优先使用..[05-21]
Effective STL Item 43:优先使用..[05-21]
Windows外壳名字空间的浏览[05-21]
Com Introduction[05-21]
VC程序调试技巧备忘录[05-21]
NO MFC - 使用 .log 调试程序[05-21]