C Program to be terminated by pressing X key

C Program to be terminated by pressing X key


#include "stdio.h"
#include "conio.h"

int main()
{
int c;

printf("Enter any characters, terminate program with X\n");

do
{
c = _getch(); /* get a character */
putchar(c); /* display the hit key */
} while (c != 'X');

printf("\nEnd of program.\n");

return 0;
}



/* Result of execution

Enter any characters, terminate program with X

(The output depends on the characters you type in.)

End of program.

*/



No comments:

Post a Comment