why using strcpy in c code example
Example 1: strcpy c implementation
#include <stdio.h>
char* strcpy(char* destination, const char* source)
{
if (destination == NULL)
return NULL;
char *ptr = destination;
while (*source != '\0')
{
*destination = *source;
destination++;
source++;
}
*destination = '\0';
return ptr;
}
int main(void)
{
char source[] = "Techie Delight";
char destination[25];
printf("%s\n", strcpy(destination, source));
return 0;
}
Example 2: strcpy implementation in c
while ((*destination++ = *source++) != '\0');