The putc()
function is a C library function, which is used to write a character to a file. This function is used to write a single character to the stream as well as advance the position of the indicator. This tutorial guides you on how to use the putc()
function in the C program.
Syntax:
int putc( int c, FILE * stream );
Example:
int main (void)
{
FILE * fileName;
char ch;
fileName = fopen("anything.txt","wt");
for (ch = 'D' ; ch <= 'S' ; ch++) {
putc (ch , fileName);
}
fclose (fileName);
return 0;
}