码迷,mamicode.com
首页 > 编程语言 > 详细

c++ 字符串拷贝以及合并

时间:2018-11-23 21:29:28      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:enter   c++   public   strcpy   合并   concat   col   iostream   gets   

 

#include<iostream>
#include<string>
using namespace std;
class stringfun
{
    char name[20];
    public:
       void concatString(char a[],char b[])
       {
          strcat(a," ");
          strcat(a,b);
          strcpy(name,a);
       }
       void display()
       {
          cout<<"\nName : "<<name;
       }
};
int main()
{
    char str1[10],str2[10];

    stringfun sf;

    cout<<"Enter your name:";
    gets(str1);
    cout<<"Enter sir name:";
    gets(str2);
    sf.concatString(str1,str2);
    sf.display();
    return 0;
}

 

c++ 字符串拷贝以及合并

标签:enter   c++   public   strcpy   合并   concat   col   iostream   gets   

原文地址:https://www.cnblogs.com/sea-stream/p/10009770.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!