“`”

<h2></h2>

<pre><code>char * strcpy(char *strDest, const char *strSrc ) { assert( (strDest != NULL) && (strSrc != NULL) ); char *address = strDest; while( (*strDest++ = * strSrc++) != ‘\0’ ); return address;}</code></pre>

要点:

使用assert断言函数,判断参数是否为NULL;

遇'\0'则停止赋值;

返回新的字符串的首地址。

<pre><code> "“`

Was this helpful?

0 / 0

发表回复 0

Your email address will not be published.