C/C++字符串使用整理

strcat 函数

功能

strcat 函数釆用两个字符串作为形参并连接它们,返回由第一个字符串和第二个字符串的所有字符组成的单个字符串

 

函数原型   

     extern char *strcat(char *dest, const char *src);

 

参数说明

     dest指向目标数组

   src指向要追加的字符串

 

在C中,使用strcat函数需要加上头文件<string.h>

在我们使用strcat函数时,要注意

strcat函数的返回值是指针dest指向的字符串

样例

#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char a[10] ="hello";
char b[10] ="world";
strcat(a,b);
cout<<a;
return 0;
}

 

输出结果

 

 




posted @ 2019-05-03 13:42  LQA00  阅读(167)  评论(0编辑  收藏  举报