Title

C语言学习—strcpy()和strcat()

C语言学习—strcpy()和strcat()

格式

  • strcpy(等待接收信息得字符数组(只需数组名),想要添加的字符串)
  • strcat(被连接的字符串,连接别人的字符串)
  • strcat返回的是指向被连接的字符串的指针

代码

#include<bits/stdc++.h>
using namespace std;
int main()
{
	char ori[50],add[50];
	
	strcpy(ori,"where?");
	strcpy(add," there");
	
	strcat(ori,add);
	
	printf("The combination of the two strings is[%s]",ori);
	
	return 0;
}

输出

The combination of the two strings is[where? there]
posted @ 2021-05-12 19:54  BeautifulWater  阅读(287)  评论(0编辑  收藏  举报