A shell has to handle the lines that are not real commands - a blank line, and a name that is not a program. Today you make both cases behave the way every real shell does instead of crashing.
Do nothing on an empty line, and report a clear error with status 127 when the program does not exist.
Two everyday inputs are not valid commands, and a shell must not fall over on either. The first is the empty line: you press Enter with nothing typed, or a line is all whitespace. Tokenizing it yields zero words, so there is simply nothing to run - loop back to the prompt and leave the last status untouched.
The second is a name that is not a program. When exec cannot find or run the
file, it fails, and the child - the only place that knows exec failed - prints
command not found and exits with the special status 127. That number is a
convention every shell shares, so tools and scripts can recognize “no such
command” specifically. Reporting it correctly is what makes your shell feel solid
rather than brittle.
if (n == 0) continue; // no words -> next prompt// in the child, if exec fails because the file is missing:fprintf(stderr, "%s: command not found\n", words[0]);_exit(127);