strmcat.c

来自「详细介绍了一篇关于pci开发的接口芯片」· C语言 代码 · 共 32 行

C
32
字号
/* strmcat.c

   Copy str2 to str1, keeping str1 <= max_str_length excluding NULL.
   Returns pointer to str1.
*/


#include <stdtypes.h>
#include <clib1.h>
#include <string.h>

CHAR *strmcat( CHAR *str1, WORD max_str_length, CHAR *str2 )
{
   LONG i = 0;
   LONG str1len = (LONG)( strlen( str1 ) );  /* current str1 size (w/o NULL) */
   CHAR *sptr;

   	if ( str1len >= max_str_length )   return(str1);
	/* point to NULL (first char to add) */
   	sptr = (CHAR *) ((LONG)str1 + str1len);/* point to NULL (first char to add) */

   while (  ((str1len + i) < max_str_length) &&  (*str2 != 0) )
   {
      *sptr++ = *str2++;
      i++;
   }

   *sptr = 0;   /* add the NULL */
   return(str1);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?