fputc(3C)
_________________________________________________________________
fputc function
Write a character to the specified stream.
_________________________________________________________________
Calling Sequence
#include <stdio.h>
FILE *fp;
char nextchar;
int fputc();
fputc(nextchar, fp);
where nextchar is the character to write out.
fp is a pointer to a FILE packet.
Description
The fputc function writes out a character to the stream you
specify. It assumes that the file is open. The include file
stdio.h defines the fputc function.
If you define the macro _NEXPAND, the stdio.h macros getc and
putc resolve to the library functions fgetc and fputc. That is,
the C program will call the library functions instead of using
the macros. This allows you to set a breakpoint at the routine
while debugging.
Returns
The fputc function returns the character written, or EOF if an
error occurs.
Related Functions
See also the fgetc, puts, and putw functions, and the putc and
putchar macros.
Example
/* Program test for the fputc() function */
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
fputc(3C)
#include <stdio.h>
FILE *fopen(), *fp;
int i = 0, fputc();
main(argc, argv)
int argc;
char *argv[];
{
fp = fopen(argv[1], "a");
while (argv[2][i] != NULL) {
fputc(argv[2][i], fp);
i++;
}
}
Three calls to the program test using the valid filename apfile
(which was previously empty) and the argument datum1, apfile and
datum2, and apfile and datum3 generate
datum1datum2datum3
as the contents of apfile. If apfile previously had contents,
these data will append to them.
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)