mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-28 16:23:10 +03:00
Added NULL check.
This commit is contained in:
parent
97be2b238b
commit
fc6a345ee5
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user