setbuf : setbuf « stdio.h « C Tutorial

Home
C Tutorial
1.Language
2.Data Type
3.String
4.printf scanf
5.Operator
6.Statement
7.Array
8.Function
9.Structure
10.Pointer
11.Memory
12.Preprocessor
13.File
14.Data Structure
15.Search Sort
16.Wide Character String
17.assert.h
18.ctype.h
19.math.h
20.setjmp.h
21.signal.h
22.stdio.h
23.stdlib.h
24.string.h
25.time.h
26.wctype.h
C / ANSI-C
C++
C++ Tutorial
Visual C++ .NET
C Tutorial » stdio.h » setbuf 
22.32.1.setbuf
ItemValue
Header filestdio.h
Declarationvoid setbuf(FILE *stream, char *buf);
Functionspecifies the buffer that stream will use or,


  1. Set buf to null to turn off buffering.
  2. The buffer must be BUFSIZ characters long.
  3. BUFSIZ is defined in .
#include <stdio.h>

int main ()
{
  char buffer[BUFSIZ];
  FILE *fp1, *fp2;

  fp1=fopen ("test.txt","w");
  fp2=fopen ("test2.txt","a");

  setbuf fp1 , buffer );
  fputs ("This is sent to a buffered stream",fp1);
  fflush (fp1);

  setbuf fp2 , NULL );
   fputs ("This is sent to an unbuffered stream",fp2);

  fclose (fp1);
  fclose (fp2);

  return 0;

}
22.32.setbuf
22.32.1.setbuf
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.