/*
*Copyright (C) 2014,烟台大学计算机学院
*All rights reserved.
*文件名称 :mian.cpp
*作 者 :韩娟
*完成日期 :2014年11月22日
*版 本 号 :v1.0
*
*问题描述 :将str1和str2连接起来,依然保存在str1
*输入描述 :略
*程序输出 :连接保存后的字符
*/
#include<iostream>
using namespace std;
int main()
{
char str1[50]="I am a happy boy\'s daddy.";
char str2[20]="I love smile !";
int i=0,j=0;
while(str1[i]!='\0')
{
i++;
}
while(str2[j]!='\0')
{
str1[i]=str2[j];
i++;
j++;
}
str1[i]='\0';//切记!!
cout<<"整理后的字符串"<<str1<<endl;
return 0;
}
知识点总结 :
这个首先把第一个数组的保存好,第二个数组的字符紧接着后面的位置复制进去即可。
学习心得 :
这个是前面两个的结合,把前面两个弄懂了,这个的难度也就降低了。