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
本文演示了如何使用strcpy和strcat函数来构建一个完整的字符串。通过具体的C语言代码示例,展示了这两个函数的基本用法及注意事项。
185

被折叠的 条评论
为什么被折叠?



