English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am writing a C++ program where I have to come out of the program when "enter" key is pressed

2006-09-19 02:43:19 · 3 answers · asked by Prem D 1 in Computers & Internet Software

3 answers

This is a simple one. Here's the answer...

main()
{
char ch;
a:ch=getch();
if(ch=='\n')
exit();
else
goto a;
}

You may include the header file stdlib.h as exit function is defined in that file.

2006-09-22 03:31:24 · answer #1 · answered by Anonymous · 1 0

check the key entered
the ascii char representing the enter key is '\r'
then use the exit function

2006-09-19 02:50:58 · answer #2 · answered by Anand 3 · 0 0

In an suitable international you would be able to upload validation to earnings the fee of the shrink back fee yet it extremely is homework so there is not any go with. replace this printf("***** make investments Calculator *****n"); to // repeat processing loop do { printf("***** make investments Calculator *****n"); Now upload this to the impressive of your development code. printf("do you opt to have a clean calculation? (beneficial:a million/No:0)n"); scanf("%d", &proceed); } mutually as (proceed==a million); proceed will additionally could desire to be declared as int. have relaxing.

2016-10-17 06:36:46 · answer #3 · answered by avey 4 · 0 0

fedest.com, questions and answers