I'm looking at the basic strcpy function. It is
char *strcpy( char *dest, const char *src );
Which reminds me of assembly language: MOV DEST, SRC
1 Answer 1
The Intel processors were not yet invented when the C library was designed, so no.
Your observation that C is similar to assembly language is correct, however. C was designed to replace assembly when Unix needed to be ported to other architectures than the original PDP-11 and many constructs map directly to the PDP-11 machine language.
I do not know if the machine language of the PDP-11 was similar to Intel (dest, src) or the reason for the API convention was just that it was this way that made most sense to the designer.
See http://www.unix.org/what_is_unix/history_timeline.html for time line.
-
1Yes, at least with the usual DEC assemblers (e.g., Macro-11), you'd also use
mov dst, src
.Jerry Coffin– Jerry Coffin2012年02月21日 04:17:44 +00:00Commented Feb 21, 2012 at 4:17
strcpy(dest, src)
ordest = src
. No, in C, these don't accomplish the exact same thing, but the general pattern (destination before source) is the same in both. If C had used a syntax like TI-BASIC'svalue → variable
(source before destination) for assignment, maybe it would have beenstrcpy(src, dest)
too.