RAD Studio
ContentsIndex
PreviousUpNext
putchar, putwchar

Header File 

stdio.h  

Category 

Console I/O Routines 

Prototype 

int putchar(int c); 

wint_t putwchar(wint_t c); 

Description 

putchar is a macro defined to be putc(c, stdout).

Note: For Win32 GUI applications, stdout must be redirected.
Return Value 

On success, putchar returns the character c. On error, putchar returns EOF. 

Example  

#include <stdio.h>
/* define some box-drawing characters */
#define LEFT_TOP  0xDA
#define RIGHT_TOP 0xBF
#define HORIZ     0xC4
#define VERT      0xB3
#define LEFT_BOT  0xC0
#define RIGHT_BOT 0xD9
int main(void)
{
   char i, j;
   /* draw the top of the box */
   putchar(LEFT_TOP);
   for (i=0; i<10; i++)
      putchar(HORIZ);
   putchar(RIGHT_TOP);
   putchar('\n');
   /* draw the middle */
   for (i=0; i<4; i++)
   {
      putchar(VERT);
      for (j=0; j<10; j++)
         putchar(' ');
      putchar(VERT);
      putchar('\n');
   }
   /* draw the bottom */
   putchar(LEFT_BOT);
   for (i=0; i<10; i++)
      putchar(HORIZ);
   putchar(RIGHT_BOT);
   putchar('\n');
   return 0;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
putchar 
putwchar 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!