#include <iostream>
using namespace std;
int main()
{
    char ch1[10] = "ab";
	char ch2[] = "abcdef";
	strncat(ch1,ch2,3); //ababc 合并char类型的字符串,第三个参数是指需要合并的字符串个数
	cout<<ch1<<endl;
	return 0;
}
//相对应的是string类的append成员函数的使用
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string str1="str1";
	string str2="hello word";
	str1.append(str2,2,3); //str1llo
	cout<<str1<<endl;
    return 0;
}

  

相关文章:

  • 2021-11-18
  • 2021-11-14
  • 2022-12-23
  • 2021-07-04
  • 2022-02-03
  • 2022-02-05
  • 2022-01-03
猜你喜欢
  • 2021-05-28
  • 2021-11-14
  • 2021-06-01
  • 2021-08-13
  • 2021-12-08
  • 2021-06-13
相关资源
相似解决方案