Sunday 9 September 2012

Concatination of two strings using c++

#include<iostream.h>
#include<stdio.h>
#include<fstream.h>
#include<conio.h>
#include<string.h>
  void main()
    {
      char name1[100],name2[100],ch;
      clrscr();
      cout<<"enter the 1st string:"<<endl;
      gets(name1);
      cout<<"enter the 2nd string:"<<endl;
      gets(name2);
      fstream f,f1;
      f.open("name1.n",ios::out|ios::skipws|ios::in);
      f<<name1;
      f1.open("name2.n",ios::out|ios::skipws|ios::in);
      f1<<name2;
      int l=strlen(name2);
      f1.seekp(l,ios::beg);
      f1<<name1;
      f.close();
      f1.close();
      f1.open("name2.n",ios::in);
      while(f1)
    {
      f1.get(ch);
      cout<<ch;
    }
    getch();
    }



No comments:

Post a Comment