C examples for stdio.h:putc
function
<cstdio> <stdio.h>
Write character to stream
int putc ( int character, FILE * stream );
Parameter | Description |
---|---|
character | The character. |
stream | FILE object |
On success, the character written is returned.
On error, EOF is returned and the error indicator ( ferror) is set.
This example program creates a file called data.txt and writes ABCDEFGHIJKLMNOPQRSTUVWXYZ to it.
#include <stdio.h> int main ()//w w w .j a v a 2 s . co m { FILE * pFile; char c; pFile=fopen("data.txt","wt"); for (c = 'A' ; c <= 'Z' ; c++) { putc (c , pFile); } fclose (pFile); return 0; }