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, ‘′ 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=’′;
return tst;
}

Related posts:

  1. Strcmp Implementation in C
  2. How to Initialize Character Array Elements to ‘\0′ in C++

Comments are closed.