This is an old revision of this page, as edited by Deryck Chan (talk | contribs) at 08:04, 21 February 2006. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Revision as of 08:04, 21 February 2006 by Deryck Chan (talk | contribs)(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)This article is actively undergoing a major edit for a little while. To help avoid edit conflicts, please do not edit this page while this message is displayed. This page was last edited at 08:04, 21 February 2006 (UTC) (18 years ago) – this estimate is cached, update. Please remove this template if this page hasn't been edited for a significant time. If you are the editor who added this template, please be sure to remove it or replace it with {{Under construction}} between editing sessions. |
putchar is a function in C programming language that writes a single character to the standard output. Its prototype is as follows:
int putchar (int character)
The character to be printed is fed into the function as an argument, and if the writing is successful, the argument character is returned. Otherwise, end-of-file is returned.
The putchar
function is specified in the C standard library header file stdio.h.
Sample usage
The following program uses getchar to read characters into an array and print them out using the putchar
function after an end-of-file character is found.
#include <stdio.h> int main() { char str; int n = 0; while (!feof(stdin)) { str = getchar(); ++n; } for (int i = 0; i < n; ++i) { putchar(str); } return 0; }
The functi
Category: