admin 管理员组

文章数量: 1184232


2023年12月16日发(作者:android版)

strcat在c语言中的用法

strcat函数是C语言的字符串库函数,用来将字符串s2复制到s1的结尾,并在末尾添加一个空字符'0'。

函数原型:

char *strcat(char *s1,const char *s2);

参数:

s1:指向字符数组的指针,用来储存复制的字符串

s2:指向需要复制的字符串

返回值:

返回s1指针。

示例:

#include

#include

int main()

{

char s1[100] = "Hello";

char s2[100] = "World";

//s1和s2连接

printf("%sn", strcat(s1, s2)); //输出HelloWorld

return 0;

}


本文标签: 字符串 用来 指针 复制 指向