axl_strncat
This commit is contained in:
parent
a6514f595c
commit
34e170d3b6
2 changed files with 17 additions and 1 deletions
|
|
@ -6,7 +6,7 @@ u32 axl_strlen(const i8* s)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
u32 len = 0;
|
||||
|
||||
while(s[len] != '\0')
|
||||
|
|
@ -62,3 +62,18 @@ i8* axl_strcat(i8* dst, const i8* src)
|
|||
|
||||
return axl_strcpy(dst + axl_strlen(dst), src);
|
||||
}
|
||||
|
||||
i8* axl_strncat(i8* dst, const i8* src, u32 n) //n actually means "not more than"
|
||||
{
|
||||
if(n == 0 || !dst || !src)
|
||||
{
|
||||
return dst;
|
||||
}
|
||||
|
||||
i8* p = dst + axl_strlen(dst);
|
||||
while (n-- && (*p++ = *src++)); //quick note: '\0' == 0
|
||||
|
||||
*p = '\0'; //in case we copied exactly n without '\0'
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,5 +7,6 @@ u32 axl_strlen(const i8* s);
|
|||
i8* axl_strcpy(i8* dst, const i8* src);
|
||||
i8* axl_strncpy(i8* dst, const i8* src, u32 n);
|
||||
i8* axl_strcat(i8* dst, const i8* src);
|
||||
i8* axl_strncat(i8* dst, const i8* src, u32 n);
|
||||
|
||||
#endif // AXL_STRING
|
||||
|
|
|
|||
Loading…
Reference in a new issue