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

# pmprintf(3)

print formatted output in a window or to standard error

## NAME

**pmprintf**, **pmflush** - print formatted output in a window or to standard error

## C SYNOPSIS

**#include \<pcp/pmapi.h\>**

**int pmprintf(const char \****fmt***, ... /\****args***\*/);**\
 **int pmflush(void);**

**cc ... -lpcp**

## DESCRIPTION

The combination of **pmprintf** and **pmflush** produces output in either an **xconfirm**(1) window, on the standard error stream, or to a file in a manner similar to [**fprintf**(3)](/fprintf/3.md). The *fmt* argument is used to control the conversion, formatting, and printing of the variable length *args* list. The output technique is controlled via an environment variable.

**pmprintf** appends the formatted message string to an internal buffer shared by the two routines, without actually producing any output.

**pmflush** causes the internal buffer to be either displayed in a window, printed on standard error, or flushed to a file and the internal buffer to be cleared.

## DIAGNOSTICS

On successful completion, **pmprintf** returns the number of characters transmitted, while **pmflush** returns a value of zero on successful completion.

For either routine, a negative value is returned if an error was encountered, and this can be passed to [**pmErrStr**(3)](/pmErrStr/3.md) to obtain the associated error message.

## FILES

**pmprintf** uses the [**mkstemp**(3)](/mkstemp/3.md) function to create a temporary file. This temporary file is deleted when **pmflush** is called.

## ENVIRONMENT

The environment variable **PCP\_STDERR** controls the output technique used by **pmflush**:

If **PCP\_STDERR** is unset, the text is written onto the *stderr* stream of the caller.

If **PCP\_STDERR** is set to the literal reserved word **DISPLAY** then the text will be displayed as a GUI dialog using **xconfirm**(1).

If **PCP\_STDERR** is set to any other value then **pmflush** interprets the value as a file name and appends the text to that file.  The file is created if it doesn't already exist, and in this case if the file creation fails, then *stderr* is used instead).

## SEE ALSO

[**pmdbg**(1)](/pmdbg/1.md), [**fprintf**(3)](/fprintf/3.md), [**mkstemp**(3)](/mkstemp/3.md), [**pmErrStr**(3)](/pmErrStr/3.md) and [**PMAPI**(3)](/PMAPI/3.md).
