I want to input string by fgets(buffer, 5, stdin) e.g. "stop", "lame", "rear"

char buffer[5];

If I type string which has a length of 20 characters, the next calls to fgets() keep partial content of previous input, what can I avoid it into Ansi C please?