-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
46 lines (29 loc) · 648 Bytes
/
main.c
File metadata and controls
46 lines (29 loc) · 648 Bytes
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
41
42
43
44
#include <stdio.h>
#include "mstring.h"
int main(void) {
char* cstr = "a\tb\tword two\tsdd sdf fsdfs";
char* cstr2 = "t he quick brown fox jumped";
char** parts;
char** parts_orig;
char* str;
printf("String: %s\n", cstr);
// Test split
// TODO free prats
parts = split(cstr2, " ");
parts_orig = parts;
printf("Split: ");
char* delim = ",";
// print
while (*parts != NULL) {
printf("%s%s", *parts, *(parts+1)==NULL?"":delim);
parts++;
}
putchar('\n');
parts = parts_orig;
// join
str = join((const char **) parts, ":");
printf("Join: %s\n", str);
free_parts(parts);
free(str);
return 0;
}