C History – Reason for Parameter Order in strcpy and memcpy

chistory

Answering a question about order of parameters it struck me that strcpy (and family) are the wrong way round. Copy should be src -> destination.

Is there a historical or architectural reason for the dest,src order in these 'C' functions? Something to do with optimization of the stack on the PDP-8 or something?

Best Answer

Think of it like an assignment operation.

A = B;  //copies the contents of B into A

Same order when using memcpy to copy an array.

memcpy(A, B, sizeof(B));  //copies the contents of B into A