From b0e376b6ba1891fcf749d22095c4f79a843a5d0f Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Wed, 27 Jun 2018 23:34:21 +0800 Subject: util.c: string builder and rename util.{c,h} to curl_util --- t/t_build_string.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 t/t_build_string.c (limited to 't') 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 +#include +#include + +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); +} + -- cgit v1.2.3