diff --git a/parser.c b/parser.c index c508fbd950c82c14884444fcbcbf18cb17296d47..b346bf0849c9a957fe5c5be4aa31f2f26c81336b 100644 --- a/parser.c +++ b/parser.c @@ -27,7 +27,7 @@ cons_cell* parse(char* input, int size) { return create_cons_cell(car_cons, cdr_cons); } else { int first_space_idx = 0; - while (input[first_space_idx] != " ") + while (input[first_space_idx] != " " && input[first_space_idx] != NULL) first_space_idx++; char buff_first[500]; @@ -39,7 +39,7 @@ cons_cell* parse(char* input, int size) { next_char++; } - strncpy(buff_other, input[next_char], size - next_char); + strncpy(buff_other, &input[next_char], size - next_char); cons_cell* cdr_cons = parse(buff_other, size-next_char); car_cons->cdr = cdr_cons; return car_cons;