how to stop a program and see what it prints

Thread Starter

EngIntoHW

Joined Apr 24, 2010
143
I'm programming in C language.

I use printf function and when I run the program, I cannot see what it prints.

What would be a proper way to hold the program at a desired point?

Edit:
I'm using Dev-C++ Compiler
 
Last edited:

t06afre

Joined May 11, 2009
5,934
Try this. I will also strongly recommend that you learn how to use the debugger. Like setting break-points, add a watch, or do some single stepping. Many beginners think this is a waste of time. But trust me then I said this is a must. Try this Google search
dev-c++ compiler debugging
Rich (BB code):
#include <stdio.h>

int main()
{
  printf ("Press ENTER to continue.\n");
  getchar (); // wait for input
  return 0;
}
Rich (BB code):
#include <stdlib.h>

int main()
{
  system ("pause"); // execute M$-DOS' pause command
  return 0;
}
 

kubeek

Joined Sep 20, 2005
5,796
That is not a good solution as it is dependant on some rather old code, better way is to start the command line and run the program from there instead of double clicking on it.
Also the approach with pause won't help you when you have some console program like gcc which just blinks and dissapears, and you want to see result. Then command line is your only option as you can't change the program you are running.
 

t06afre

Joined May 11, 2009
5,934
That is not a good solution as it is dependant on some rather old code, better way is to start the command line and run the program from there instead of double clicking on it.
Also the approach with pause won't help you when you have some console program like gcc which just blinks and dissapears, and you want to see result. Then command line is your only option as you can't change the program you are running.
Maybe, but as I understand it. The OP is running the program from the compiler enviroment just to learn C. Then this method will work more than good.
 
Top