函数 mystrcpy() 实现了strcpy() ,复制源字符串到目的串,返回一个指向目的串的指针
code
#include <stdio.h>
char *mystrcpy(char *destination, const char *source)
{
char *destination_ptr;
/* Store the starting position
* of the destination string */
destination_ptr = destination;
/* Copy the value at source
* pointer to destination pointer
* and increment both the pointers
* until NULL is encountered. */
while (*destination++ = *source++);
/* Return the pointer
* which is pointing to the
* begining of the destination
* string */
return (destination_ptr);
}
int main()
{
char source[] = "This is the source string";
char destination[50];
printf("%s", mystrcpy(destination, source));
}