# Print Formatted

printf, sprintfに対応する処理を行います。

{% hint style="info" %}
本ライブラリではMacro Poland氏のprintf,sprintfライブラリを利用しています。\
<https://github.com/mpaland/printf>
{% endhint %}

## printfmt

ストリーム[`IStreamOut`](/references/basics/twe/untitled.md)オブジェクトに対して`<<`演算子の右オペランドとして利用します。

```cpp
printfmt(const char*fmt, ...)
ISteramOut& operator << (IStreamOut& strm, printfmt f)

//例
  the_screen << printfmt("%04X", 0x12ab) << crlf;
```

`printfmt`クラスのコストラクタのパラメータの１番目`fmt`に書式を指定します。以降のパラメータはC++テンプレートのパラメータパックで実装されており可変数引数となっています。printfのように書式に対応した引数を指定します。printfと違い引数の数は最大４つに制限されます。

## fPrintf()

ストリーム[`IStreamOut`](/references/basics/twe/untitled.md)オブジェクトを出力先としてfprintfと同じ処理を行います。

```cpp
int fPrintf(TWE::IStreamOut& fp, const char* format, ...)
```

１番目の引数がストリームオブジェクトとなる点を除きfprintfと同じ使い方です。

## snPrintf()

snprintfの処理を行います。

```cpp
int snPrintf(char* buffer, size_t count, const char* format, ...)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mwm5.twelite.info/references/basics/twe/print-formatted.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
