Write a C program to copy a string to another using a pointers.
Write a C program to copy a string to another using a pointers.
#include<stdio.h>
void main()
{
char str1[100],str2[100],*p1,*p2;
p1=str1;
p2=str2;
printf("Enter a string\n");
scanf("%s",str2);
while(*p2!='\0')
{
*p1=*p2;
p1++;
p2++;
}
*p1=‘\0’;
printf("Copied string is = %s",str1);
}
Comments
Post a Comment