第十六周-字符串增多字符

第十六周-字符串增加字符
/* 
* Copyright (c) 2012, 烟台大学计算机学院                  
* All rights reserved.                     
* 文件名称:test.cpp                     
* 作者:邱学伟                    
* 完成日期:2012 年12月12日                  
* 版本号:v1.0                                        
* 输入描述:无                     
* 问题描述:在字符串str2后面增加符号"//comment:"                
* 程序输出:
* 问题分析:                    
* 算法设计:略                     
*/   
#include<iostream>
using namespace std;
int main()
{
  char str1[50]="I am a happy boy.",str2[50];
  int i=0,j=0;
  for(i=0;str1[i]!='\0';i++)
  {  
    if(str1[i]!=' ')
    {
      str2[j]=str1[i];
      j++;
    }
  }
  cout<<"输入附加字符:"<<endl;
  for(j=15;j<=23;j++)
  {
	  cin>>str2[j];
  }
  str2[j]='\0';//切记!!
  cout<<"整理后的字符串"<<str2<<endl;
  return 0;
}
第十六周-字符串增多字符