> char b[21];
> fgets(b,22,thes)
Your problem IS buffer overflow, not merely some minor inconvenience you can fix later.
Lying to fgets about the size of your buffer is no better than using gets().