Getch( ) function waits for a keypress. - C Data Type

C examples for Data Type:char

Introduction

getch() does not echo the character to the screen.

The getche( ) function is the same as getch( ), but the key is echoed.

Demo Code

#include <stdio.h>
#include <conio.h>
#include <ctype.h>

int main(void)
{
   char ch;/*ww  w  .j ava 2 s. com*/

   printf("Enter some text (type a period to quit).\n");
   do {
      ch = getch();

      if (islower(ch)) ch = toupper(ch);
      else ch = tolower(ch);

      putchar(ch);
   } while (ch != '.');
   return 0;
}

Result


Related Tutorials