Skip to content

Commit ffd0531

Browse files
authored
Merge pull request #1477 from rotarymars/master
new page bufsiz.md
2 parents 700975a + fd7a507 commit ffd0531

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

reference/cstdio.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
| [`_IOFBF`](/reference/cstdio/iofbf.md.nolink) | 入出力を完全にバッファリングする指定のための整数定数 | |
2222
| [`_IOLBF`](/reference/cstdio/iolbf.md.nolink) | 入出力を行バッファリングする指定のための整数定数 | |
2323
| [`_IONBF`](/reference/cstdio/ionbf.md.nolink) | 入出力をバッファリングしない指定のための整数定数 | |
24-
| [`BUFSIZ`](/reference/cstdio/bufsiz.md.nolink) | バッファサイズを表す整数定数 | |
24+
| [`BUFSIZ`](/reference/cstdio/bufsiz.md) | バッファサイズを表す整数定数 | |
2525
| [`EOF`](/reference/cstdio/eof.md) | ファイルの終端であることを表す`int`型の整数定数 | |
2626
| [`FOPEN_MAX`](/reference/cstdio/fopen_max.md.nolink) | 実装によって保証されるファイルを開ける最低限の数を表す整数定数 | |
2727
| [`FILENAME_MAX`](/reference/cstdio/filename_max.md) | 実装によって保証されるファイル名の最大の長さを表す整数定数 | |

reference/cstdio/bufsiz.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# BUFSIZ
2+
* cstdio[meta header]
3+
* macro[meta id-type]
4+
5+
```cpp
6+
#define BUFSIZ unspecified
7+
```
8+
* unspecified[italic]
9+
10+
## 概要
11+
[`setbuf()`](/reference/cstdio/setbuf.md.nolink)関数で使われる標準入出力のバッファサイズを表すマクロ。
12+
13+
このマクロは、標準入出力関数で使用されるデフォルトのバッファサイズを定義する。値は実装依存であるが、一般的には512バイトや1024バイトなどの値が使用される。
14+
15+
## 例
16+
```cpp example
17+
#include <cstdio>
18+
19+
int main() {
20+
// BUFSIZの値を表示
21+
std::printf("BUFSIZ = %d\n", BUFSIZ);
22+
23+
// バッファサイズを指定してファイルを開く
24+
char buffer[BUFSIZ];
25+
std::FILE* file = std::fopen("test.txt", "w");
26+
if (file) {
27+
// バッファを設定
28+
std::setbuf(file, buffer);
29+
std::fprintf(file, "Hello, World!\n");
30+
std::fclose(file);
31+
}
32+
33+
return 0;
34+
}
35+
```
36+
* BUFSIZ[color ff0000]
37+
* std::printf[link /reference/cstdio/printf.md]
38+
* std::fopen[link /reference/cstdio/fopen.md]
39+
* std::setbuf[link /reference/cstdio/setbuf.md.nolink]
40+
* std::fprintf[link /reference/cstdio/fprintf.md]
41+
* std::fclose[link /reference/cstdio/fclose.md]
42+
43+
### 出力例
44+
```
45+
BUFSIZ = 1024
46+
```
47+
48+
## 処理系
49+
50+
- [Clang](/implementation.md#clang): ??
51+
- [GCC](/implementation.md#gcc): ??
52+
- [Visual C++](/implementation.md#visual_cpp): ??

0 commit comments

Comments
 (0)