-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge_args.c
40 lines (38 loc) · 1.32 KB
/
merge_args.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* merge_args.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fnacarel <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/15 05:35:03 by fnacarel #+# #+# */
/* Updated: 2023/01/15 11:21:16 by fnacarel ### ########.fr */
/* */
/* ************************************************************************** */
#include "./encoder.h"
/*
Create an string which is the combination of every argv (except 0) combined,
no spaces are put in between.
*/
char *merge_args(int argc, char **argv)
{
int i;
int j;
int k;
char *str;
i = 1;
j = 0;
k = 0;
while (i < argc)
j += strlen(argv[i++]);
str = calloc(sizeof(char), j + 1);
i = 1;
while (i < argc)
{
j = 0;
while (argv[i][j])
str[k++] = argv[i][j++];
i++;
}
return (str);
}