#include<stdio.h>
#include<string.h>
int str_cpy(char *destination, const char*source)
{
if (destination == NULL || source == NULL)
{
return -1;
}
for (; *source != '\0'; )
{
*destination++ = *source++;
}
*destination = '\0';
return 0;
}
int str_cpy2(char *destination, const char*source)
{
if (destination == NULL || source == NULL)
{
return -1;
}
while ((*destination++ = *source++) != '\0');
return 0;
}
int main()
{
char p[16];
char *q = "hello world";
strcpy(p, q);
memset(p, 0x00, sizeof(p));
str_cpy(p, q);
memset(p, 0x00, sizeof(p));
str_cpy2(p, q);
memset(p, 0x00, sizeof(p));
return 0;
}