_cprintf

Formats and prints to the console.

int _cprintf( const char *format [, argument] ... );

Routine Required Header Compatibility
_cprintf <conio.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

_cprintf returns the number of characters printed.

Parameters

format

Format-control string

argument

Optional parameters

Remarks

The _cprintf function formats and prints a series of characters and values directly to the console, using the _putch function to output characters. Each argument (if any) is converted and output according to the corresponding format specification in format. The format has the same form and function as the format parameter for the printf function. Unlike the fprintf, printf, and sprintf functions, _cprintf does not translate linefeed characters into carriage return–linefeed (CR-LF) combinations on output.

Example

/* CPRINTF.C: This program displays
 * some variables to the console.
 */

#include <conio.h>

void main( void )
{
   int      i = -16, h = 29;
   unsigned u = 62511;
   char     c = 'A';
   char     s[] = "Test";

   /* Note that console output does not translate \n as
    * standard output does. Use \r\n instead.
    */
   _cprintf( "%d  %.4x  %u  %c %s\r\n", i, h, u, c, s );
}

Output

-16  001d  62511  A Test
 

Console and Port I/O Routines

See Also   _cscanf, fprintf, printf, sprintf, vfprintf