diff --git a/libc/string/strcpy.cpp b/libc/string/strcpy.cpp index 1b367024..fdb6a94e 100644 --- a/libc/string/strcpy.cpp +++ b/libc/string/strcpy.cpp @@ -26,9 +26,9 @@ extern "C" char* strcpy(char* dest, const char* src) { - char* origdest = dest; - while ( *src ) - *dest++ = *src++; - *dest = '\0'; - return origdest; + size_t index; + for ( index = 0; src[index]; index++ ) + dest[index] = src[index]; + dest[index] = '\0'; + return dest; } diff --git a/libc/wchar/wcscpy.cpp b/libc/wchar/wcscpy.cpp index 89f9caad..9e5d2325 100644 --- a/libc/wchar/wcscpy.cpp +++ b/libc/wchar/wcscpy.cpp @@ -26,9 +26,9 @@ extern "C" wchar_t* wcscpy(wchar_t* dest, const wchar_t* src) { - wchar_t* origdest = dest; - while ( *src ) - *dest++ = *src++; - *dest = '\0'; - return origdest; + size_t index; + for ( index = 0; src[index]; index++ ) + dest[index] = src[index]; + dest[index] = '\0'; + return dest; }