/*
* Copyright (c) 2011, 烟台大学计算机学院
* All rights reserved.
* 作 者:王锴英
* 完成日期:2012 年 12 月 11 日
* 版 本 号:v1.0
* 输入描述:输入字符串1,字符串2
* 问题描述:略
* 程序输出:输出新字符串(字符串相加)
* 算法设计:略
*/
NO 1.
#include <iostream>
using namespace std;
int main( )
{
char str1[50],str2[40];
int i=0,j=0;
cout<<"输入字符串1:"<<endl;
gets(str1);
cout<<"输入字符串2:"<<endl;
gets(str2);
while(str1[i]!='\0')
i++;
while(str2[j]!='\0')
str1[i++]=str2[j++];
str1[i]='\0';
cout<<"新的字符串为:"<<str1<<endl;
return 0;
}
NO 2.
#include <iostream>
#include<string>
using namespace std;
int main( )
{
char str1[50]="12 yue 21",str2[40]=" wo men yi qi";
cout<<"新的字符串为:"<<strcat(str1,str2)<<endl;
return 0;
}