Strcpy in C




Arrays and Strings in Tamil


Strcpy

  • The strcpy(destination, source) function copies the source string in destination.
 String Copy

String Copy

Example

#include<stdio.h> 
#include <string.h>
void main()
{
	char ch[20]={'k', 'a', 'a', 's', 'h',  'i', 'v', 'i', 'n', 'f','o','t','e','c','h','\0’}; 
	char ch2[20];
	strcpy(ch2,ch);
	printf("Value of second string is: %s",ch2);
	getch();
}
 StrCpy

StrCpy

Output

Value of second string is: kaashivinfotech

String Copy Without Using StringCpy()

#include <stdio.h>
#include <string.h>
void main()
{
       char string1[20], string2[20];
       int i;
       printf("Enter the value of string 1 ");
       scanf("%s",string1);
       for(i=0; string1[i]!='\0'; i++)
       	string2[i]=string1[i];
       string2[i]='\0';
       printf(" The value of string2 is: ");
       printf("%d",string2);
       getch();
}
 String Copy Without Using Strcpy()

String Copy Without Using Strcpy()

Output :

Enter the value of string1 kaashivinfotech
The value of string2 is : kaashivinfotech


Related Searches to Strcpy in C

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×