---
name: "libtmpfile"
section: "3"
platform: "linux"
package: "netpbm"
version: "10.86.51-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libtmpfile"
---

# libtmpfile(3)

create a temporary unnamed file

## NAME

pm\_tmpfile() - create a temporary unnamed file

## SYNOPSIS

```
#include <netpbm/pm.h>
FILE *
pm_tmpfile(void);
```

## EXAMPLE

This simple example creates a temporary file, writes "hello world" to it, then reads back and prints those contents.

```
#include <netpbm/pm.h>
FILE * myfileP;
myfile = pm_tmpfile();
fprintf(myfile, "hello world\n");
fseek(myfileP, 0, SEEK_SET);
fread(buffer, sizeof(buffer), 1, myfileP);
fprintf(STDOUT, "temp file contains '%s'\n", buffer);
fclose(myfileP);
```

## DESCRIPTION

This library function is part of **Netpbm**(1) .

**pm\_tmpfile()** creates and opens an unnamed temporary file. It is basically the same thing as the standard C library **tmpfile()** function, except that it uses the **TMPFILE** environment variable to decide where to create the temporary file. If **TMPFILE** is not set or is set to something unusable (e.g. too long), **pm\_tmpfile()** falls back to the value of the standard C library symbol **P\_tmpdir**, just like **tmpfile()**.

Unlike **tmpfile()**, **pm\_tmpfile()** never returns NULL. If it fails, it issues a message to Standard Error and aborts the program, like most libnetpbm routines do.

If you need to refer to the temporary file by name, use **pm\_make\_tmpfile()** instead.

## HISTORY

**pm\_tmpfile()** was introduced in Netpbm 10.20 (January 2004).

## DOCUMENT SOURCE

This manual page was generated by the Netpbm tool 'makeman' from HTML source.  The master documentation is at

-

  **http://netpbm.sourceforge.net/doc/libtmpfile.html**
