V4/usr/man/man3/putc.3
.th PUTC III 6/12/72
.sh NAME
putc \*- buffered output
.sh SYNOPSIS
.ft B
.nf
mov $filename,r0
jsr r5,fcreat; iobuf
.s3
fcreat(file, iobuf)
char *file;
struct buf *iobuf;
.s3
.ft R
(get byte in r0)
.ft B
jsr r5,putc; iobuf
.s3
putc(c, iobuf)
int c;
struct buf *iobuf;
.s3
.ft R
(get word in r0)
.ft B
jsr r5,putw; iobuf
.s3
[putw not available from C]
.s3
jsr r5,flush; iobuf
.s3
fflush(iobuf)
struct buf *iobuf;
.fi
.ft R
.sh DESCRIPTION
.it Fcreat
creates
the given file (mode 666) and sets up the buffer
.it iobuf
(size 518 bytes);
.it putc
and
.it putw
write a byte or word respectively
onto the file;
.it flush
forces the contents of the buffer to be written, but
does not close the file.
The format of the buffer is:
.s3
.nf
.ft B
iobuf: .=.+2 / file descriptor
.=.+2 / characters unused in buffer
.=.+2 / ptr to next free character
.=.+512. / buffer
.ft R
.s3
Or in C,
.s3
.ft B
.nf
struct buf {
int fildes;
int nunused;
char *nxtfree;
char buff[512];
};
.ft R
.fi
.s3
.it Fcreat
sets the error bit (c-bit) if the
file creation failed (from C, returns \*-1); none of the other routines
returns error information.
.s3
Before terminating, a program should call
.it flush
to force out the last of the output
.it (fflush
from C).
.s3
The user must supply
.it iobuf,
which should begin on a word boundary.
.s3
To write a new file using the same buffer, it
suffices to call
.it [f]flush,
close the file,
and
call
.it fcreat
again.
.sh "SEE ALSO"
creat(II), write(II), getc(III)
.sh DIAGNOSTICS
error bit possible
on
.it fcreat
call.
.sh BUGS