Skip to main content

Write a 'c' program to copy the one string into another using strcpy() function?

 

To copy the one string into another using function 


strcpy( ) : This function is used to copy the one string into another.The general form is ,void                     strcpy(target,source);

Consider the following program ,
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main( )
{
char str1[50],str2[50];
int i;
clrscr( );
printf("\nEnter the string :");
scanf("%s",str1);

strcpy(str2,str1);
printf("\nResult : %s",str2);
getch( );
}

output :
Enter the string : computer
Result : computer


Join us on Facebook: Click Here  

Comments