putc Function

Puts a character to the stream.

Include

<stdio.h>

Prototype

int putc(int c, FILE *stream);

Arguments

c
character to be written
stream
pointer to FILE structure

Return Value

Returns the character or EOF if an error occurs or end-of-file is reached.

Remarks

putc is the same as the function fputc.

Example

#include <stdio.h>

int main(void)
{
  char *y;
  char buf[] = "This is text\n";
  int x;

  x = 0;
 
  for (y = buf; (x != EOF) && (*y != '\0'); y++)
  {
    x = putc(*y, stdout);
    putc('|', stdout);
  }
}

Example Output

T|h|i|s| |i|s| |t|e|x|t|
|