Search Windows and Linux Networking

Friday, December 2, 2011

Simple C program asking user to press ENTER Key and ignore other all keys before continue

Simple C program asking user to press ENTER Key and ignore other keys before continue

 /* Simple program asking user to press ENTER Key and ignore other */
/* Author: Sandeep           Date: 1 DEC 2011 */

#include<stdio.h>
#include<conio.h>
main()
{  char name[80];
   printf("Enter your Name:");
   scanf("%s",&name);
   printf("\nPress \"ENTER\" Key to Continue...");
  
   while(getch()!=0x0d);   /* This is the statement  checking input key with value 0x0d hex value of Enter */
  
   printf("\nHello %s how are you?",name);
   printf("\nPress Any key to Exit");
   getch();
   return(0);
}

No comments:

Post a Comment