User-defined copy strings 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;
main()
{
char name[10],name1[10]={0};
cout<<"Enter the name:"<<endl;
gets(name);
cout<<endl;
cout<<"the name entered is:"<<endl;
puts(name);
char *ptr,*ptr1;
ptr=name;
ptr1=name1;
while(*ptr!='\0')
{
*ptr1=*ptr;
*ptr++;
*ptr1++;
}
cout<<endl;
cout<<"Copied string is:"<<endl;
puts(name1);
getch();
return 0;
}
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;
main()
{
char name[10],name1[10]={0};
cout<<"Enter the name:"<<endl;
gets(name);
cout<<endl;
cout<<"the name entered is:"<<endl;
puts(name);
char *ptr,*ptr1;
ptr=name;
ptr1=name1;
while(*ptr!='\0')
{
*ptr1=*ptr;
*ptr++;
*ptr1++;
}
cout<<endl;
cout<<"Copied string is:"<<endl;
puts(name1);
getch();
return 0;
}
No comments:
Post a Comment