mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-03 14:49:29 +00:00
use of while loop in strncpy function
This commit is contained in:
parent
4c43784fd1
commit
0c23d50bdf
1 changed files with 4 additions and 4 deletions
|
@ -16,14 +16,14 @@
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
sc_strncpy(char *dest, const char *src, size_t n) {
|
sc_strncpy(char *dest, const char *src, size_t n) {
|
||||||
size_t i;
|
size_t i=0;
|
||||||
for (i = 0; i < n - 1 && src[i] != '\0'; ++i)
|
while(i < n - 1 && src[i] != '\0')
|
||||||
dest[i] = src[i];
|
dest[i] = src[i++];
|
||||||
if (n)
|
if (n)
|
||||||
dest[i] = '\0';
|
dest[i] = '\0';
|
||||||
return src[i] == '\0' ? i : n;
|
return src[i] == '\0' ? i : n;
|
||||||
}
|
}
|
||||||
|
//use of while loop insted of using for loop
|
||||||
size_t
|
size_t
|
||||||
sc_str_join(char *dst, const char *const tokens[], char sep, size_t n) {
|
sc_str_join(char *dst, const char *const tokens[], char sep, size_t n) {
|
||||||
const char *const *remaining = tokens;
|
const char *const *remaining = tokens;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue