Revision as of 08:10, 21 February 2006 editDeryck Chan (talk | contribs)Administrators22,733 edits →See also← Previous edit |
Latest revision as of 05:17, 26 April 2023 edit undoSteel1943 (talk | contribs)Autopatrolled, Extended confirmed users, Page movers, Pending changes reviewers, Rollbackers, Template editors197,068 edits Rcats |
(25 intermediate revisions by 15 users not shown) |
Line 1: |
Line 1: |
|
|
#REDIRECT ] |
|
{{lowercase|title=putchar}} |
|
|
|
|
|
|
|
{{Redirect category shell| |
|
'''putchar''' is a ] in ] that writes a single ] to the ]. Its prototype is as follows: |
|
|
|
{{R with history}} |
|
:<code>int putchar (int character)</code> |
|
|
|
{{R to anchor}} |
|
|
|
|
⚫ |
}} |
|
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, ] is returned. |
|
|
|
|
|
The <code>putchar</code> function is specified in the ] ] ]. |
|
|
|
|
|
==Sample usage== |
|
|
The following program uses ] to read characters into an array and print them out using the <code>putchar</code> function after an ] 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 function specifies the reading length's maximum value at 1000 characters; however if the end-of-file character doesn't come up after 1000 characters are read, different ]s and different ]s will give different results: Some cases will terminate the program at a ], while some others will read the remaining string into the non-] area of the memory, possibly causing errors to other programs. |
|
|
|
|
|
==See also== |
|
|
*] |
|
|
*] |
|
|
*] |
|
|
|
|
|
==References== |
|
|
* |
|
|
|
|
|
] |
|