Added NULL check.

This commit is contained in:
A Silent Cat 2018-07-24 13:38:45 -05:00
parent 97be2b238b
commit fc6a345ee5
1 changed files with 1 additions and 0 deletions

View File

@ -5,6 +5,7 @@
const char *hello(void)
{
char * ans = malloc(sizeof(char) * strlen("Hello, World!"));
if (!ans) return NULL;
strcpy(ans,"Hello, World!");
/* string is pointer of the first character */