Need to Rewrite strcpy() function

We have a new assignment: rewrite the strcpy() function that is usually accessable with the <cstring.h> include. I thought of a way of doing it with the use of pointers however, my instructor has outlawed them because we have not reached that lesson yet. If someone here can provide a hint or a solution I belive that I would learn alot from it. So, strcpy(dest, origin); no pointers any suggestions?

That's not a pointer?
What is the astric after the return value in the function mean?
////////////////////////////////////////////////////////
char * mystrcpy(char to[], const char from[], size_t size)
{
register int i;

for (i=0; i <= size; i++)
to[i] = from[i];

to[size] = 0;
return to;
}
///////////////////////////////////////////////////////
I already gave up and used a pointer. The assignmentis due today....I just had a thought, is that a virtual function? If it is, were not allowed to use those either :-)
Thanks anyway though.

The asterisk is part of the return type. vpopper's mystrcpy() function actually returns a pointer-to-char. With parentheses, the prototype would be

Code:

(char *) mystrcpy (char to[], const char from[], size_t size);

That's not a pointer?

I'm not sure what exactly you're referring to, but I'll assume you're talking about the functions' parameters. Strictly speaking they are pointers, yes. The []-brackets are more a hint to the programmer that the function expects an array-of-type rather than a pointer-to-type.

Although a bit late (since you already handed in your assignment), I think the idea was that you didn't use pointer arithmetic to copy the string.

The thing is, it doesn't make sense to write a string copying routine if you're not working with the original destination array. A reference to it has to be passed to the function one way or another. C implements the "pass by reference" concept with pointers; there's no way around that.

"A poor programmer is he who blames his tools."
http://analyser.oli.tudelft.nl/