Assuming that the code is not blocked, and the next line is executed immediately (as you seemed to point out at an early stage in the question, and in the comment ), you have a common problem when mixing input data other than line and line.
What happens is that there is a new line in the buffer, and fgets sees this, reads and returns, instead of doing what you really want: ignoring it, and then reading the line.
The solution is to simply ignore the part yourself and then call fgets:
#include <stdio.h>
Note that this is also common, and it is recommended that you match the ignore with scanf (or another non-line input) to turn it into a line input. In this case, you can change it so that you can specify the difference between entering "42 abc" and "42" (in the case of "Enter number"). Some people simply use phages everywhere, and then parse this string with sscanf, and although this works, it is not necessary.
Roger Pate
source share