views:

470

answers:

4

Edit:

I don't know what this user originally wanted, and hopefully they'll edit their question to let us know, but otherwise, let's use this question to answer (or give links to) the following common console window issues:

  • How do you capture the output of a console application in your program (for instance, running a build process and getting the output in your IDE)?
  • How do you get your console application to hang around long enough to see the output when you hit "run" in the IDE? (ie, getch for C, some IDEs have options to set, what common/popular pause and wait for keypress routines do you use to keep the console window open long enough to see the output? This applies to lots of languages - list your method)

Original question:

How to view console application output screen(black screen).Please mention in detail.

A: 

If it's a graphical application that happens to write messages to standard output, open your favorite terminal application and type in the command there. If its output exceeds the output buffer of your terminal, pipe it through 'more' or 'less'.

eswald
+1  A: 

Keeping the console window open in for C++ in a standard's compliant way (not platform specific):

#include <iostream>
#include <limits>

int main() {

  // Rest of the code    

  //Clean the stream and ask for input
  std::cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
  std::cin.get();
  return 0;
}

Source.

Adam Davis
A: 

Keeping the console window open in C:

/* Example waits for a character input */
#include <stdio.h>

int main()
{
  /* Put your code here */
  getchar();
  return 0;
}

getchar is standards compliant, while getch (a common usage) is platform specific.

Adam Davis
A: 

In c# I just put a break point at the end of my code to keep the console window open. I used to use Console.Read(); but got sick of typing it...

Edit: btw I just use this for my debugging purposes. If it needs to be a feature then Console.Read();