现在的位置: 首页 > 综合 > 正文

strcat 拼接两个字符串

2014年01月14日 ⁄ 综合 ⁄ 共 652字 ⁄ 字号 评论关闭

strcat is short for string catenate.


// crt_strcpy.c
// compile with: /W1
// This program uses strcpy
// and strcat to build a phrase.

#include <string.h>
#include <stdio.h>

int main( void )
{
   char string[80];

   // Note that if you change the previous line to
   //   char string[20];
   // strcpy and strcat will happily overrun the string
   // buffer.  See the examples for strncpy and strncat
   // for safer string handling.

   strcpy( string, "Hello world from " ); // C4996
   // Note: strcpy is deprecated; consider using strcpy_s instead
   strcat( string, "strcpy " );           // C4996
   // Note: strcat is deprecated; consider using strcat_s instead
   strcat( string, "and " );              // C4996
   strcat( string, "strcat!" );           // C4996
   printf( "String = %s\n", string );
}

Output

String = Hello world from strcpy and strcat

抱歉!评论已关闭.