fputc() Write a Character to a Stream
#include <stdio.h>
int fputc(c,stream);
int c; Character to be written
FILE *stream; Pointer to file structure
fputc() writes a single character to 'stream' at the current
position.
Returns: The character written, if successful. EOF is returned to
indicate an error. Since EOF is a legitimate integer
value, use ferror() to verify an error condition.
Notes: fputc() is identical to putc(), except that fputc() is a
function and putc() is a macro.
-------------------------------- Example ---------------------------------
The following statements open a file and write the contents of a
buffer to it.
#include <stdio.h>
FILE *stream;
char buffr[10] = "0123456789";
int i;
int ch;
main()
{
if ((stream = fopen("num.dta","r+")) != NULL) {
for (i = 0; i <= 9; i++)
if ((ch = fputc(buffr[i],stream)) != EOF)
;
}
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster