std::fputc, std::putc

Header: <cstdio>

Writes a character ch to the given output stream stream.

# Declarations

int fputc( int ch, std::FILE* stream );
int putc( int ch, std::FILE* stream );

# Parameters

# Return value

On success, returns the written character.

# Example

#include <cstdio>
 
int main()
{
    for (char c = 'a'; c != 'z'; c++)
        std::putc(c, stdout);
 
    // putchar's return value is not equal to the argument
    int r = 0x102A;
    std::printf("\nr = 0x%x\n", r);
 
    r = std::putchar(r);
    std::printf("\nr = 0x%x\n", r);
}

# See also