Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fopen(3S)

getc(3S)

malloc(3C)

putc(3S)

SETBUF(3S)  —  UNIX 3.0

NAME

setbuf − assign buffering to a stream

SYNOPSIS

#include <stdio.h>

setbuf (stream, buf)
FILE ∗stream;
char ∗buf;

DESCRIPTION

Setbuf is used after a stream has been opened but before it is read or written.  It causes the character array buf to be used instead of an automatically allocated buffer.  If buf is the constant pointer NULL, input/output will be completely unbuffered. 

A manifest constant BUFSIZ tells how big an array is needed:

char buf[BUFSIZ];

A buffer is normally obtained from malloc(3C) upon the first getc or putc(3S) on the file, except that output streams directed to terminals, and the standard error stream stderr are normally not buffered. 

A common source of error is allocation of buffer space as an “automatic” variable in a code block, and then failing to close the stream in the same block. 

SEE ALSO

fopen(3S), getc(3S), malloc(3C), putc(3S). 

May 16, 1980

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026