diff --git a/lib/str.c b/lib/str.c index 0153b87..b95af7b 100644 --- a/lib/str.c +++ b/lib/str.c @@ -1,10 +1,11 @@ #include "str.h" unsigned int strlen(char* str) { - char* c; - for( c = str; *c != '\0'; c++ ) // search for end-of-string - - return (unsigned int)(c - str); // get size by delta-address + unsigned int len = 0; + for( char* c = str; *c != '\0'; c++ ) // search for end-of-string + len++; + + return len; } char* strcat(char* buf, char* str) { @@ -20,5 +21,7 @@ char* strcat(char* buf, char* str) { cc++; } + *(buf + bufferlen + cc) = '\0'; // add end-of-string + return buf; }