diff --git a/exercism/hello_world/hello_world.c b/exercism/hello_world/hello_world.c index 45349900..74aaa5cb 100644 --- a/exercism/hello_world/hello_world.c +++ b/exercism/hello_world/hello_world.c @@ -4,10 +4,7 @@ const char *hello(void) { - char * ans = malloc(sizeof(char) * strlen("Hello, World!")); - if (!ans) return NULL; - strcpy(ans,"Hello, World!"); - + char * ans = strdup("Hello, World!"); /* string is pointer of the first character */ return ans; }