------------------------------------------------------------------------------
MC logo
String Copy Implementation I
[^] Code Examples
------------------------------------------------------------------------------
<<C String Facility strcpy1.c String Copy Implementation II>>
/*
 * An implementation of strcpy.
 */
char *strcpy1(char *target, const char *source)
{
        int i;

        for(i = 0; source[i] != '\0'; ++i)
                target[i] = source[i];
        target[i] = source[i];

        return target;
}

#include <stdio.h>
int main()
{
        char s1[] = "Hi there, fred!";
        char s2[40];

        strcpy(s2, s1);
        printf("%s\n", s2);
}

The string library functions are not "magic" but are simply functions written in C. Here is an implementation of strcpy.
Reading: pp. 58-66
<<C String Facility String Copy Implementation II>>