C语言中strcat是干什么用的,他是什么呢

谢谢。
2025-03-04 19:11:12
推荐回答(3个)
回答1:

strcat 语法: #include char *strcat( char *str1, const char *str2 );功能:函数将字符串str2 连接到str1的末端,并返回指针str1. 例如: printf( "Enter your name: " ); scanf( "%s", name ); title = strcat( name, " the Great" ); printf( "Hello, %s\n", title ); 不明白再追问

回答2:

哈哈,粘别人的=============字符串连接函数,函数返回指针,两个参数都是指针.第一个参数所指向的内存的地址必须能容纳两个字符串连接后的大小.
#include
#include //这一句一定要加,包含了strcat的源代码
main()
{
char s1[]="hello",s2[]="programs";
strcat(s1,s2);
printf("%s\n",s1);//输出 helloprograms
}

回答3:

刚才我们团队的一位队员回答的很详细了,其实就是连接字符串的函数,这是语法部分,只要理解实质就好。