Why does strcpy take it's arguments in reverse order
c, c-strings, cstring, syntax
Solution
They wanted to match memcpy's syntax.
`char * strcpy ( char * destination, const char * source );`
`void * memcpy ( void * destination, const void * source, size_t num );`
Other C functions use this order too.
A basic strcpy(...) implementation would be (skipping castings):
char * strcpy ( char * destination, const char * source ) {
return memcpy(destination, source, strlen(source) + 1);
}
Problem
Almost every other program or function designed to copy one object into another uses the basic convention copy(source, destination) Even common logic would lead one to the conclusion that you are copying something FROM here to THERE. Why does strcpy use the exact opposite convention? It only serves to confuse people attempting to use the function. Surely the author of strcpy thought of this while he was writing the function? Or does the strcpy function predate this now-ubiquitous usage convention?