十六、C++字符串(一)
十六、C++字符串(一)1、原生字符串实现将两个字符串拼接
//原生字符串实现将两个字符串拼接#include #include int main(){ char strA = "123";//定义字符串 char strB = "456"; setlocale(LC_ALL, "chs"); char strC; //定义一个临时的字符数组 memcpy(strC,strA,strlen(strA));//先通过memcpy将字符串A放入临时字符数组中 memcpy(strC + strlen(strA), strB, strlen(strB)+1);//再将字符串B拼接到临时字符数组,加1是为了将字符串结尾的0也拷贝进来 std::cout
页:
[1]