|
| fputc| Summary | |
#include <stdio.h>
int fputc (
int c, /* character to write */
FILE *stream); /* file stream to write to */
| | Description | | The fputc function writes a single character, c, to stream and increments the file pointer. The fputc function is in the RL-FlashFS library. The prototype is defined in stdio.h. | | Return Value | | The fputc function returns the character written. A return value of EOF indicates an error. | | See Also | | fgetc, fputs, ungetc | | Example | |
#include <rtl.h>
#include <stdio.h>
void tst_fputc (void) {
FILE *fout;
int ch;
fout = fopen ("Test.txt","w");
if (fout == NULL) {
printf ("File open error!\n");
}
else {
// copy the stdin to a file
while ((ch = getchar ()) != EOF) {
fputc (ch, fout);
}
fclose (fout);
}
}
|
|
|