strcat源码

#include <iostream>

using namespace std;





/***

 *char *strcat(dst, src) - concatenate (append) one string to another

 *

 *Purpose:

 *       Concatenates src onto the end of dest.  Assumes enough

 *       space in dest.

 *

 *Entry:

 *       char *dst - string to which "src" is to be appended

 *       const char *src - string to be appended to the end of "dst"

 *

 *Exit:

 *       The address of "dst"

 *

 *Exceptions:

 *

 *******************************************************************************/





/////////////////////////////////////////////////////////////////////////////////

/*说明:

  1. __cdecl 是C Declaration的缩写(declaration,声明),表示C语言默认的函数调用方法:所有参数从右到左依次入栈,这些参数由调用者清除,称为手动清栈。被调用函数不会要求调用者传递多少参数,调用者传递过多或者过少的参数,甚至完全不同的参数都不会产生编译阶段的错误。

  2.  在字符串dest之后连接上src

  3.  按照ANSI(American National Standards Institute)标准,不能对void指针进行算法操作,即不能对void指针进行如p++的操作,所以需要转换为具体的类型指针来操作,例如char *。(引用网友的结论)

*/



char * __cdecl strcat (

                       char * dst,

                       const char * src

                       )

{

    char * cp = dst;

    

    while( *cp )

        cp++;                   /* find end of dst */

    

    while( *cp++ = *src++ ) ;       /* Copy src to end of dst */



    return( dst );                  /* return dst */

    

}
--------------------- 
https://blog.csdn.net/barry_yan/article/details/8453554 

猜你喜欢

转载自blog.csdn.net/Think88666/article/details/84311506