diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-06-27 23:34:21 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-06-28 00:16:51 +0800 |
commit | b0e376b6ba1891fcf749d22095c4f79a843a5d0f (patch) | |
tree | 5008f76cf09bbda7b979180997a8cb3e142f0899 /t | |
parent | e6d9edc048efb5b19d79bbe7871b2ff779d72311 (diff) | |
download | matrix-curl-b0e376b6ba1891fcf749d22095c4f79a843a5d0f.tar.xz |
util.c: string builder
and rename util.{c,h} to curl_util
Diffstat (limited to 't')
-rw-r--r-- | t/t_build_string.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/t/t_build_string.c b/t/t_build_string.c new file mode 100644 index 0000000..f49cc2b --- /dev/null +++ b/t/t_build_string.c @@ -0,0 +1,19 @@ +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +char * alloc_build_string(const char *ss[]); + +int main() +{ + const char *greets[] = {"hello", " world", " all", NULL}; + char *greet = alloc_build_string(greets); + char *greet2 = alloc_build_string((const char *[]){ + "hello world", " all", NULL + }); + printf("%d\n", strcmp(greet, "hello world all")); + printf("%d\n", strcmp(greet2, "hello world all")); + free(greet); + free(greet2); +} + |