The mkstemp function replaces the six trailing Xs of the string pointed to by template with a unique set of characters, and returns a file descriptor for the file open for reading and writing. The string pointed to by template should look like a filename with six trailing X's. The mkstemp function replaces each X with a character from the portable file-name character set, making sure not to duplicate an existing filename. If the string pointed to by template does not contain six trailing Xs, -1 is returned.