dos_compilers/Zortech C++ v206/SOURCE/CLIB/TMPNAM.C
2024-07-02 07:30:38 -07:00

36 lines
894 B
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*_ tmpnam.c Wed Jan 18 1989 Modified by: Walter Bright */
/* Copyright (C) 1985-1989 by Walter Bright */
/* All rights reserved. */
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
/*******************************
* Generate temporary filename.
* At least TMP_MAX different names are tried.
* Input:
* string Pointer to buffer to store filename into that
* is at least L_tmpnam bytes long. If NULL, then
* tmpnam() will use an internal static buffer which
* is overwritten by each call to tmpnam().
* Returns:
* pointer to filename generated
*/
char *tmpnam(char *string)
{ int save;
static char buffer[L_tmpnam];
static unsigned tmpnum = 1;
if (!string)
string = buffer;
save = errno;
do
{
itoa(tmpnum++,string,10);
} while (findfirst(string,0xFF));
errno = save;
return string;
}