Software & Finance





C Programming (Turbo C++ Compiler) Printing Characters on the Screen using getch and putch





I have given here the source code illustrating the use getch and putch with printing the characters on the display screen.


Source Code


#include <stdio.h>

#include <conio.h>

 

void main()

{

      char  ch;

      printf("Program for printing characters. Enter Esc Key to exit\n");

      while(1)

      {

            ch = getch();

            //printf("%d", ch);

            if(ch == 27)

                  break;

            else if(ch == 13)

                  printf("\n");

            else if(ch == 9)

                  printf("\t");

            else

                  putch(ch);

      }

}

Output


Program for printing characters. Enter Esc Key to exit

 

This is for testing from www.softwareandfinance.com