Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** my_concat_params | ||
4 | ** File description: | ||
5 | ** Returns a string with all the arguments (argc and argv) concatenated | ||
6 | */ | ||
7 | /** | ||
8 | * @file my_concat_params.c | ||
9 | * @brief The file containing the my_concat_params function | ||
10 | * @author Nicolas TORO | ||
11 | */ | ||
12 | |||
13 | #include "my.h" | ||
14 | |||
15 | 1 | char *my_concat_params(int argc, char **argv) | |
16 | { | ||
17 | char *result; | ||
18 | 1 | int len_result = 0; | |
19 | |||
20 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (int i = 0; i < argc; i++) |
21 | 4 | len_result = len_result + my_strlen(argv[i]); | |
22 | 1 | result = malloc(sizeof(char) * (len_result + argc)); | |
23 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (int j = 0; j < argc; j++) { |
24 | 4 | result = my_strcat(result, argv[j]); | |
25 | 4 | result = my_strcat(result, "\n"); | |
26 | } | ||
27 | 1 | result[len_result + argc] = '\0'; | |
28 | 1 | return result; | |
29 | } | ||
30 |