| I/O manipulators | ||||
| Print functions(C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
| Synchronized Output | ||||
(C++20) | ||||
| Types | ||||
| Error category interface | ||||
(C++11) | ||||
(C++11) |
| Types and objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <cstdio> | ||
Writes a characterch to the given output streamstream.
Internally, the character is converted tounsignedchar just before being written.
In C,putc() may be implemented as a macro, which is disallowed in C++. Therefore, calls tostd::fputc() andstd::putc() always have the same effect.
Contents |
| ch | - | character to be written |
| stream | - | output stream |
On success, returns the written character.
On failure, returnsEOF and sets theerror indicator (seestd::ferror()) onstream.
#include <cstdio> int main(){for(char c='a'; c!='z'; c++) std::putc(c,stdout); // putchar's return value is not equal to the argumentint r=0x102A;std::printf("\nr = 0x%x\n", r); r=std::putchar(r);std::printf("\nr = 0x%x\n", r);}
Possible output:
abcdefghijklmnopqrstuvwxyr = 0x102A*r = 0x2A
| writes a character tostdout (function)[edit] | |
C documentation forfputc,putc | |