| << Prev | Beej's Guide to C | Next >> |
Write a single character to the console or to a file.
#include <stdio.h> int putc(int c, FILE *stream); int fputc(int c, FILE *stream); int putchar(int c);
All three functions output a single character, either to the console
or to a
putc() takes a character argument, and outputs it to the
specified
putchar() writes the character to the console, and is the same as calling putc(c, stdout).
All three functions return the character written on success, or EOF on error.
// print the alphabet
#include <stdio.h>
int main(void)
{
char i;
for(i = 'A'; i <= 'Z'; i++)
putchar(i);
putchar('\n'); // put a newline at the end to make it pretty
return 0;
}
| << Prev | Beej's Guide to C | Next >> |