Monday, January 31, 2011

Pointers and Arrays in C++

User-defined concatenation of stings,using pointers.
If this program make any errors please let me know,i will try to help you out.

#include<iostream>
#include<conio.h>
#include<string.h>
using namespace std;
void myconct(char *,char *);
main()
{
char a[80],b[80];
cout<<"Enter 1st string:";
gets(a);
cout<<"Enter 2nd string:";
gets(b);
char *p1,*p2;
p1=a;p2=b;
myconct(p1,p2);
getch();
      return 0;
      }
void myconct(char *a,char *b)
{
  int l1,l2;
  l1=strlen(a);
  l2=strlen(b);
  int l;
  l=l1+l2;
  int i=0;
   
for(int i=0;i<=l2;i++)

{

a[l1+i]=b[i];

}

cout<<a;

}
                   
                     








    

No comments:

Post a Comment