Advertisement
RobertDeMilo

RB2.5 Буферизация в выходных потоках

Apr 15th, 2024
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. // Файловый поток ofstream не сразу выводит в файл, а буферизует выведенные в него данные
  2. // cout и cerr ведут себя точно так же
  3. // манипулятор endl не только выводит перевод строки, но и сбрасывает буфер потока в файл
  4.  
  5. #include <iostream>
  6. #include <vector>
  7. #include <fstream>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     ofstream out("output.txt");
  14.  
  15.     /*for (int i = 0; i < 25; ++i)
  16.     {
  17.         out << "London is the capital of GreatBritain. "
  18.             << "I am travellong down the river"
  19.             << '\n';
  20.     }*/
  21.    
  22.     for (int i = 0; i < 25; ++i)
  23.     {
  24.         out << "London is the capital of GreatBritain. "
  25.             << "I am travellong down the river"
  26.             << endl;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement