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

# pmsprintf(3)

formatted string conversion

## NAME

**pmsprintf** - formatted string conversion

## C SYNOPSIS

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

**int pmsprintf(char \****str***,** **size\_t** *size***,** **const char \****fmt***,** **... /\****args***\*/);**

**cc ... -lpcp**

## DESCRIPTION

Safe string formatting interface that wraps the [**vsnprintf**(3)](/vsnprintf/3.md) call.

It differs primarily in that **pmsprintf** guarantees that the output buffer *str* will be null-terminated even when the provided buffer *size* is insufficient to contain the formatted string. In this case a null-terminated truncated string will be returned in *str*.

In the case of a failure in the underlying *vsnprintf* interface, a null-terminated empty string will be returned in *str*, and the return value will be zero.

## DIAGNOSTICS

On successful completion, **pmsprintf** returns the number of characters written to the supplied buffer, not including the null terminator.

The return code is always zero or more, never negative.

## SEE ALSO

[**vsnprintf**(3)](/vsnprintf/3.md), [**pmprintf**(3)](/pmprintf/3.md) and [**PMAPI**(3)](/PMAPI/3.md).
