From 88c024464a199aa995fdfc422f9d4c4da216c048 Mon Sep 17 00:00:00 2001 From: Akira Takahashi Date: Thu, 2 Feb 2023 00:02:13 +0900 Subject: [PATCH] =?UTF-8?q?print(ln)=20:=20=E5=87=BA=E5=8A=9B=E5=85=88?= =?UTF-8?q?=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=99=E3=82=8B=E4=BE=8B=E3=80=81?= =?UTF-8?q?=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=88=E3=81=AE=E4=BE=8B=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reference/print/print.md | 25 ++++++++++++++++++++++++- reference/print/println.md | 25 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/reference/print/print.md b/reference/print/print.md index 088c0647bd..da96a425dc 100644 --- a/reference/print/print.md +++ b/reference/print/print.md @@ -84,19 +84,42 @@ namespace std { ## 例 +### 基本的な使い方 ```cpp example #include int main() { std::print("Hello {} World\n", 42); + + // 出力先を指定 + std::print(stdout, "Hello {} World\n", 42); // 標準出力に出力 + std::print(stderr, "Hello {} World\n", 42); // 標準エラーに出力 } ``` * std::print[color ff0000] -### 出力 +#### 出力 ``` Hello 42 World +Hello 42 World +Hello 42 World +``` + +### モジュールをインポートする例 +```cpp example +#import std; +#import std.compat; + +int main() +{ + std::print("Hello {} World\n", 42); // OK + + // stdout / stderrはマクロとして定義される。 + // モジュールはマクロをエクスポートしないので、 + // stdout / stderrは使用できない + std::print(stdout, "Hello {} World\n", 42); // エラー!stdoutが見つからない +} ``` ## バージョン diff --git a/reference/print/println.md b/reference/print/println.md index 5ecd8f35ac..e588f774d2 100644 --- a/reference/print/println.md +++ b/reference/print/println.md @@ -52,19 +52,42 @@ namespace std { ## 例 +### 基本的な使い方 ```cpp example #include int main() { std::println("Hello {} World", 42); + + // 出力先を指定 + std::println(stdout, "Hello {} World", 42); // 標準出力に出力 + std::println(stderr, "Hello {} World", 42); // 標準エラーに出力 } ``` * std::println[color ff0000] -### 出力 +#### 出力 ``` Hello 42 World +Hello 42 World +Hello 42 World +``` + +### モジュールをインポートする例 +```cpp example +import std; +import std.compat; + +int main() +{ + std::println("Hello {} World", 42); // OK + + // stdout / stderrはマクロとして定義される。 + // モジュールはマクロをエクスポートしないので、 + // stdout / stderrは使用できない + std::println(stdout, "Hello {} World", 42); // エラー!stdoutが見つからない +} ``` ## バージョン