TheAlgorithms-C/exercism/hello_world/hello_world.c

14 lines
288 B
C
Raw Normal View History

2018-01-25 05:24:43 +08:00
#include "hello_world.h"
2018-01-27 02:38:12 +08:00
#include <stdlib.h>
#include <string.h>
2018-01-25 05:24:43 +08:00
const char *hello(void)
{
2018-01-27 02:38:12 +08:00
char * ans = malloc(sizeof(char) * strlen("Hello, World!"));
2018-07-25 02:38:45 +08:00
if (!ans) return NULL;
2018-01-27 02:38:12 +08:00
strcpy(ans,"Hello, World!");
2018-01-25 05:24:43 +08:00
/* string is pointer of the first character */
2018-01-27 02:38:12 +08:00
return ans;
2018-01-25 05:24:43 +08:00
}