about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/main.c b/main.c
index c8b10e6..2b79001 100644
--- a/main.c
+++ b/main.c
@@ -37,7 +37,8 @@ int main() {
     fprintf(s.defout, s.prompt, s.command_count, s.last_op);
     s.last_op = 0;
     char *endptr = NULL;
-    fgets(buf, BUF_SIZE, s.defbuf);
+    char *check = fgets(buf, BUF_SIZE, s.defbuf);
+    if (check == NULL) exit(0);
     buf[strcspn(buf, "\n")] = 0;
     double interpreted = strtod(buf, &endptr);
     if (errno == ERANGE) {