30 June 2010

my_strcpy

#include <stdio.h>

void my_strcpy(const char*, char*);

static char str1[80] = "Good";
static char str2[80];

int main(void)
{
puts(str2);
my_strcpy(str1, str2);
puts(str2);
return 0;
}

void my_strcpy(const char* src, char* dest){
char* p;
p = dest;
while (*src!= '\0'){
*p++ = *src++;
}
*p = '\0';
}
Post a Comment