1.strcat函数
具体格式:
strcat(字符数组1,字符数组2)
说明:
字符串连接函数,其功能是将字符数组2中的字符串连接到字符数组1中字符串的后面,并删去字符串1后的串结束标志”\0”。需要注意的是字符数组的长度要足够大,否则不能装下连接后的字符串。
例子:
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main(){
char str1[30],str2[20];
cout<<"please input string1:"<<endl;
gets(str1);
cout<<"please input string2:"<<endl;
gets(str2);
strcat(str1,str2);
cout<<"Now the string is:"<<endl;
puts(str1);