mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-22 04:25:01 +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
|
||||
sc_strncpy(char *dest, const char *src, size_t n) {
|
||||
size_t i;
|
||||
for (i = 0; i < n - 1 && src[i] != '\0'; ++i)
|
||||
dest[i] = src[i];
|
||||
size_t i=0;
|
||||
while(i < n - 1 && src[i] != '\0')
|
||||
dest[i] = src[i++];
|
||||
if (n)
|
||||
dest[i] = '\0';
|
||||
return src[i] == '\0' ? i : n;
|
||||
}
|
||||
|
||||
//use of while loop insted of using for loop
|
||||
size_t
|
||||
sc_str_join(char *dst, const char *const tokens[], char sep, size_t n) {
|
||||
const char *const *remaining = tokens;
|
||||
|
|
Loading…
Add table
Reference in a new issue