Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c589a4

Browse files
authored
cpp_tips: note flushing for interactive problems
1 parent7952d74 commit0c589a4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎src/others/cpp_tips.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tags:
1010
-`std::ios_base::sync_with_stdio(false)`: by default, C++ works with C++ iostreams (like`std::cin`) and C style stdio streams (like`stdin`) by synchronizing them.
1111
Since you should never need C style I/O (like`scanf`,`printf`), in C++, disabling this synchronization will make C++ I/O competitive with C style`scanf`.
1212
-`std::cin.tie(0)`: By default, iostreams flush cout every time you read from cin, so that you will always display any output before reading any input.
13-
If you are not solving an interactive problem, i.e. you don't require interleavinginputs and outputs, you candisable this automatic flushing to make I/O faster.
13+
You can disable this automatic flushing to make I/O faster. The exception is for interactive problems with interleavedinputs and outputs,for whichyou caneither not use`cin.tie(0)` or flush explicitly with`cout.flush()`/`cout.endl`.
1414

1515
References:
1616
[Dr. Dobbs - The Standard Librarian: IOStreams and Stdio](https://www.drdobbs.com/the-standard-librarian-iostreams-and-std/184401305),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp