Export (0) Print
Expand All
div
eof
Expand Minimize
This topic has not yet been rated - Rate this topic

_fputchar, _fputwchar 

Writes a character to stdout.


int _fputchar(
   int c 
);
wint_t _fputwchar(
   wchar_t c 
);

Parameters

c

Character to be written.

Each of these functions returns the character written. For _fputchar, a return value of EOF indicates an error. For _fputwchar, a return value of WEOF indicates an error. If c is NULL, these functions generate an invalid parameter exception, as described in Parameter Validation. If execution is allowed to continue, they return EOF (or WEOF) and set errno to EINVAL.

For more information about these and other error codes, see _doserrno, errno, _sys_errlist, and _sys_nerr.

Both of these functions writes the single character c to stdout and advances the indicator as appropriate. _fputchar is equivalent to fputc( stdout ). It is also equivalent to putchar, but implemented only as a function, rather than as a function and a macro. Unlike fputc and putchar, these functions are not compatible with the ANSI standard.

Generic-Text Routine Mappings
Tchar.h routine _UNICODE and _MBCS not defined _MBCS defined _UNICODE defined

_fputtchar

_fputchar

_fputchar

_fputwchar

Function Required header Compatibility

_fputchar

<stdio.h>

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

_fputwchar

<stdio.h> or <wchar.h>

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For more compatibility information, see Compatibility in the Introduction.

// crt_fputchar.c
// This program uses _fputchar
// to send a character array to stdout.
 

#include <stdio.h>

int main( void )
{
    char strptr[] = "This is a test of _fputchar!!\n";
    char *p = NULL;

    // Print line to stream using _fputchar. 
    p = strptr;
    while( (*p != '\0') && _fputchar( *(p++) ) != EOF )
      ;
}

Output

This is a test of _fputchar!!
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.