| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | ** EPITECH PROJECT, 2023 | ||
| 3 | ** my_strncpy | ||
| 4 | ** File description: | ||
| 5 | ** Copies a string (src) and paste it on another string (dest) | ||
| 6 | ** with a defined size (n) | ||
| 7 | */ | ||
| 8 | /** | ||
| 9 | * @file my_strncpy.c | ||
| 10 | * @brief The file containing the my_strncpy function | ||
| 11 | * @author Nicolas TORO | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include "my.h" | ||
| 15 | |||
| 16 | 1 | char *my_strncpy(char *dest, char const *src, int n) | |
| 17 | { | ||
| 18 | 1 | int len = my_strlen(src); | |
| 19 | |||
| 20 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
|
11 | for (int i = 0; i < n; i++) { |
| 21 | 10 | dest[i] = src[i]; | |
| 22 | } | ||
| 23 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (len < n) { |
| 24 | 1 | dest[len] = '\0'; | |
| 25 | } | ||
| 26 | 1 | return dest; | |
| 27 | } | ||
| 28 |