3 ms·
> Strcpy has to iterate through all the elements because it copies them. This would happen regardless. It doesn't do strlen. Iterate all the elements and copy
by tjoff 8y ago
> Strcpy has to iterate through all the elements because it copies them. This would happen regardless. It doesn't do strlen.
Iterate all the elements and copy a fixed size is two very different things.
strcpy has to read, byte for byte, and check it for null (which is exactly what strlen does). A "real" copy would just blindly copy a chunk of memory with no other processing on it. The speed difference is huge.
- WalterBright 8y agoYou're right. I apologize for using strlen metaphorically rather than literally.