You want to do this:
strcmp(buffer, “exitn”)
That is, when you enter your string and press “enter”, the newline becomes a part of buffer.
Alternately, use strncmp(), which only compares n characters of the string
fgets() is returning the string “exitn” — unlike gets(), it preserves newlines.