if (!fgets(string, 999, stdin))
return NULL;
temp = strchr(string, '\n');
- *temp = '\0';
+ if (temp)
+ *temp = '\0';
return string;
}
if (!fgets(string, 999, stdin))
return NULL;
temp = strchr(string, '\n');
- *temp = '\0';
+ if (temp)
+ *temp = '\0';
return string;
}