3 ms·
You could implement strcpy(a, b) as memcpy(a, b, strlen(b) + 1), but it would be slower, since it makes two separate passes over b (one to calculate the size, o
by comex 5y ago
You could implement strcpy(a, b) as memcpy(a, b, strlen(b) + 1), but it would be slower, since it makes two separate passes over b (one to calculate the size, one to copy).
The post seems to be arguing that in most cases where you would call strcpy, you should know the size already, because otherwise you wouldn't know whether the source string was short enough to fit in the destination buffer.