COHERENT manpages
This page displays the COHERENT manpage for putc() [Write character into stream].
List of available manpages
Index
putc() -- STDIO Function (libc)
Write character into stream
#include <stdio.h>
int putc(c, fp) char c; FILE *fp;
putc() writes character c into the file stream to which fp points. It
returns c upon success.
Example
The following example demonstrates putc(). It opens an ASCII file and
prints its contents on the screen. For another example of putc(), see the
entry for getc().
#include <stdio.h>
main()
{
FILE *fp;
int ch;
int filename[20];
printf("Enter file name: ");
gets(filename);
if ((fp = fopen(filename,"r")) != NULL) {
while ((ch = fgetc(fp)) != EOF)
putc(ch, stdout);
} else
printf("Cannot open %s.\n", filename);
fclose(fp);
}
See Also
fputc(),
getc(),
libc,
putchar()
ANSI Standard, §7.9.7.8
POSIX Standard, §8.1
Diagnostics
putc() returns EOF when a write error occurs.
Notes
Because putc() is a macro, arguments with side effects may not work as
expected.




