![]() |
VOOZH | about |
In C, the putc() function is used to write a character passed as an argument to a given stream. It is a standard library function defined in the <stdio.h> header file. The function first converts the character to unsigned char, then writes it to the given stream at the position indicated by the file pointer, and finally increments the file pointer by one.
int putc(int ch, FILE *stream);
In this example, we will write a single character to a file using putc().
File has been modified !
If we open the generated file.txt, it will print the following content:
Output
A
In this example, we will use a for loop to write all the characters between A to Z to a file using putc(). See the following code:
File has been modified !
If we open the generated file.txt, it will print the following content:
Output
ABCDEFGHIJKLMNOPQRSTUVWXYZ