Help us and donate little Bitcoins to pay the server costs: 1AXLPuRUBYc1JczTW4XS65GL6oWjNP2Vt2

User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer







because of the inhumane working conditions at amazon in Germany, I will offer the Amazon app no more! (ARD Reportage)
c:stdio.h:setbuf

setbuf

    void setbuf(FILE *stream, char *buffer);

Controls buffering for stream stream. For null buf, turns off buffering, otherwise equivalent to (void)setvbuf(stream, buf, _IOFBF, BUFSIZ).

setbuf is deprecated use setvbuf instead

C Sourcecode Example

/* 
 * setbuf example code
 * http://code-reference.com/c/stdio.h/setbuf 
 */
 
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
 
int main( void )
{
  FILE *stream = fopen("test.txt", "w");
  FILE *stream2 = fopen("test2.txt","w");
 
  char buffer[100];
  char buffer2[BUFSIZ];  
 
  setbuf(stream, buffer);
  fputs("Buffered input for test.txt", stream);
  fflush(stream);
  fclose(stream);
 
  setbuf(stream2, buffer2);
  fputs("Buffered input for test2.txt", stream2);
  fflush(stream2);
  fclose(stream2);
 
  return 0;
}
  output: ./setbuf
  

content of test.txt

Buffered input for test.txt

content of test2.txt

Buffered input for test2.txt
advertising
c/stdio.h/setbuf.txt · Last modified: 2013/01/22 22:02 (external edit)

The new Question & Answer System is online and waiting for your Questions about Programming problems http://ask.code-reference.com Impressum