.TH putc() "" "" "STDIO Function (libc)"
.PC "Write character into stream"
.B "#include <stdio.h>"
\fBint putc(\fIc\^\fB, \fIfp\^\fB) char \fIc\^\fB; FILE *\fIfp\^\fB;\fR
.PP
.B putc()
writes character
.I c
into the file stream to which
.I fp
points.
It returns
.I c
upon success.
.SH Example
The following example demonstrates
.BR putc() .
It opens an ASCII file and prints its contents on the screen.
For another example of
.BR putc() ,
see the entry for
.BR getc() .
.DM
#include <stdio.h>
main()
{
	FILE *fp;
	int ch;
	int filename[20];
.DE
.DM
	printf("Enter file name: ");
	gets(filename);
.DE
.DM
	if ((fp = fopen(filename,"r")) != NULL) {
		while ((ch = fgetc(fp)) != EOF)
			putc(ch, stdout);
	} else
		printf("Cannot open %s.\en", filename);
	fclose(fp);
}
.DE
.SH "See Also"
.Xr "fputc()," fputc
.Xr "getc()," getc
.Xr "libc," libc
.Xr "putchar()" putchar
.br
\*(AS, \(sc7.9.7.8
.br
\*(PX Standard, \(sc8.1
.SH Diagnostics
.B putc()
returns
.B EOF 
when a write error occurs.
.SH Notes
Because
.B putc()
is a macro, arguments with side effects may not work as expected.
