fputc Function

Puts a character to the stream.

Attention: This function is not implemented by MPLAB XC8 for PIC MCUs. It is implemented by all other compilers, but MPLAB XC8 for AVR MCUs has limited support of data streams.

Include

<stdio.h>

Prototype

int fputc(int c, FILE * stream);

Arguments

c
character to be written
stream
pointer to the open stream

Return Value

Returns the character written or EOF if a write error occurs.

Remarks

The function writes the character to the output stream, advances the file-position indicator and returns the character as an unsigned char converted to an int.

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 = fputc(*y, stdout);
    fputc('|', stdout);
  }
}

Example Output

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