Strcpy implementation in C

Strcpy copies the string “src” into the area pointed to by “dest”. This area must be big enough to hold the contents of “src”.
Strcpy ends copying of data when it reaches NULL character (Say, ‘\0’ or 0) and then copies NULL at the end of destination data
Syntax: char *strcpy(char *src, char *dest)

Strcpy implementation in C
#include< stdio.h >
char *strcopy(char *, char *);
int main()
{
char a[20]=”HelloWorld”;
char *c;
char *temp;
temp=strcopy(&a,&c);
printf(“\nString is %s”,temp);
return 0;
}
char *strcopy(char *src, char *dest)
{
char *tst=dest;
while(*dest++ = *src++);
*dest=’\0′;
return tst;
}

About mohan

This is Mohan Jayapalan author of TechPages Blog.I am a part time blogger and Currently working for private Software Concern.

© Copyright 2010-2016 www.techpages.org · All Rights Reserved · Powered by WordPress ·