How can you follow that program? The formatting is inconsistent making it very difficult to read. See this
I can't be certain if this is the cause because of your formatting but with all the
fgets() in your program, why are you using that single
scanf() ? See this too.