MSC V5.x, tempnam function gotcha

Clayton Cramer cramer at optilink.UUCP
Fri Jul 1 10:21:36 AEST 1988


I ran into an interesting quirk (I hesitate to call it a bug) of the
tempnam function in Microsoft C.  The tempnam function provides a fairly
painless way to create temporary file names in the directory specified
by your TMP environment variable.  However, there is a slight quirk.

The manual says that the temporary file name is created in "Directory
specified by TMP" if "TMP environment variable is set, and directory
specified by TMP exist."

So, when I tried to use it, it behaved as though TMP wasn't set, or the
directory specified didn't exist.  The cause, it turns out, was that
my AUTOEXEC.BAT file says, "set TMP=e:" and tempnam doesn't consider
"e:" by itself to be a directory -- it needs "e:\".

As I said, it's not really a bug -- it does EXACTLY what it says it will
do, but it's only obvious to the very literal-minded (or a computer)
that "e:" is not a directory in this context.

Clayton E. Cramer



More information about the Comp.lang.c mailing list