#include<stdio.h>
/* Again, the function is designed to accept the values of two character
pointers, i.e. addresses */
main (int argc, char *argv[]) {
char strA[80] = "A string to beused for demonstration only.";
char strB[80];
char *my_strcpy(char *destination, char *source) {
char *p = destination;
while (*source != '\0') {
*p++ = *source++;
}
*p = '\0';
return destination;
}
my_strcpy(strB, strA);
puts(strB);
}
/*
I have deviated slightly from the form used in standard C which
would have the prototype:
char *my_strcpy(char *destination, const char *source);
Here the "const" modifier is used to assure the user
that the function will not modify the contents pointed to by the
source pointer.
*/
return to top