add strlcpy
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@412 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
6109cf575a
commit
6c82f5086f
|
@ -335,6 +335,26 @@ char *rt_strncpy(char *dest, const char *src, rt_ubase_t n)
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will copy string no more than n bytes.
|
||||||
|
*
|
||||||
|
* @param dest the string to copy
|
||||||
|
* @param src the string to be copied
|
||||||
|
* @param n the maximum copied length
|
||||||
|
*
|
||||||
|
* @return the result with '\0' at the end
|
||||||
|
*/
|
||||||
|
char *rt_strlcpy(char *dest, const char *src, rt_ubase_t n)
|
||||||
|
{
|
||||||
|
char *tmp = (char *) dest, *s = (char *) src;
|
||||||
|
|
||||||
|
while(n--)
|
||||||
|
*tmp++ = *s++;
|
||||||
|
*tmp = '\0';
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will compare two strings with specified maximum length
|
* This function will compare two strings with specified maximum length
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue