/*Program to Copy one string to another using pointer.*/
#include
#include
main()
{
char a[80],b[80],*pa,*pb;
int i=0;
clrscr();
printf("Given first string ");
scanf("%s",a);
pa=&a[0];
pb=&b[0];
while(*pa!='\0')
{
*pb=*pa;
pa++;
pb++;
}
*pb='\0';
printf("\nCopied string is");
puts(b);
}
nice code
ReplyDeleteif you explain the code it ll be more help ful.
ReplyDeletethnks for the code..........
Another way is :
ReplyDeleteUnder FOR loop
First we take all values of string one into
pointer------>pointer=string1;
Then we copy all values in pointer to string
two-------->pointer=scanf("%s",&string2);