Syntax of putc()

int putc(int ch, FILE *stream);

Parameters

  • ch – This is the character to be written.
  • stream – This is a pointer to a FILE object that identifies the stream where the character is to be written.

Return Value

  • If the operation is successful, the function returns the character written.
  • If an error occurs or the end of the file is reached, it returns EOF.

C Library Function – putc()

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.

Similar Reads

Syntax of putc()

int putc(int ch, FILE *stream);...

Examples of C putc()

Example 1:...