Program to copy one string into other with using library function [ strcpy ]

July 4, 2024 No Comments » Hits : 540





Copy One String Into Other Using Library Function

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str1[100];
char str2[100];
printf("\nEnter the String 1 : ");
gets(str1);
strcpy(str2,str1);
printf("\nCopied String : %s",str2);
getch();
}

Output :

Enter the String 1 : c4learn
Copied  String : c4learn

Explain me ?

  1. Copy “str1″ into “str2″.
  2. Result will be stored in “str2″
  3. strcpy functions is included in Header File : string.h

Functions Required :

Incoming search terms: