#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char first[] = "timo";
char second[] = "SB";
int lenth = strlen(first) + strlen(second) + 1;
char *result=new char[lenth];
strcpy(result,first);
strcat(result,second);
while(*result)
{
cout<<*result;
*result++;
}
system("pause");
delete [] result;
return 0;
#include<cstring>
using namespace std;
int main()
{
char first[] = "timo";
char second[] = "SB";
int lenth = strlen(first) + strlen(second) + 1;
char *result=new char[lenth];
strcpy(result,first);
strcat(result,second);
while(*result)
{
cout<<*result;
*result++;
}
system("pause");
delete [] result;
return 0;
}
本文通过一个简单的C++程序展示了如何将两个字符串连接起来,并如何遍历并打印连接后的字符串。该程序首先定义了两个字符串,然后使用`strcpy`和`strcat`函数进行连接,最后通过一个`while`循环逐字符输出结果。
936

被折叠的 条评论
为什么被折叠?



