gets has no right to exist. But sprintf does. It's a workaround for some old embedded C compilers that lack the safe string copy functions (strcpy_s, strlcpy.)
Which brings it back again to my initial comment:
"I don't understand why functions like gets and sprintf weren't removed from the standard and headers a long time ago."
And by a long time I mean before 1989 (certainly before 1999).