C/File/Stream Buffer


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск

Change stream buffering: how to setbuf

#include <stdio.h>
int main ()
{
  char buffer[256];
  FILE *file1, *file2;
  file1=fopen ("f1.txt","w");
  file2=fopen ("f2.txt","a");
  setbuf ( file1 , buffer );
  fputs ("This is sent to the buffered stream: file1",file1);
  fflush (file1);
  setbuf ( file2 , NULL );
  fputs ("This is sent to the unbuffered stream: file2",file2);
  fclose (file1);
  fclose (file2);
  return 0;
}