GeekInterview.com
Series: Subject: Topic:
Question: 25 of 267

C/C++ black screen opens and closes

While executing a program in C++, it happens the black screen opens and closes automatically without displaying the output(program is correct). How to recover from this situation?
Asked by: Interview Candidate | Asked on: Sep 25th, 2011
Showing Answers 1 - 4 of 4 Answers
surendrap

Answered On : Sep 26th, 2011

View all answers by surendrap

use getch();

  
Login to rate this answer.
Sugan

Answered On : Sep 26th, 2011

Yeah .. Surendra is right..

This happens when getch() or getche() is not given at the end.

getch will let the output to be displayed till the user enters a character.
As soon as the user enters a character it transfers the control back to the main function.
Then it continues executing the rest of the lines.



  
Login to rate this answer.
jobin

Answered On : Oct 4th, 2011

getch();

  
Login to rate this answer.
Paul_Singh

Answered On : Feb 7th, 2012

View all answers by Paul_Singh

Run it from a command prompt.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.