Console application

Edit:

I don't know what this user originally wanted and hopefully they will edit their question to inform us, but if not, let me use this question to answer (or provide a link) to the following common console window problems: / p>

  • How can you get the output of a console application in your program (for example, start the build process and get the output in your IDE)?
  • How can you hold the console application long enough to see the result when you hit "run" in the IDE? (i.e. getch for C, some IDEs have options to set what is the common / popular pause and wait for keypress routines you use to open the console window long enough to see the result? This applies to many languages ​​- list yours method)

Original question:

How to view the output of a console application screen (black screen). detail.

+1


source to share


4 answers


Keeping the console window open for C ++ is standard (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

+1


source


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



0


source


Saving an open console window in C:

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

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

      

getchar is standards compliant and getch (common usage) is platform specific.

-Adam

0


source


In C #, I just put a breakpoint at the end of my code to open a console window. I used to use Console.Read (); but he's tired of typing it ...

Edit: btw I'm just using this for my own debugging purposes. If it should be a function, then Console.Read ();

0


source







All Articles