mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-24 22:39:52 +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