Puts a character to the stream.
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> /* for fputc, EOF, stdout */
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|
|