Monday, May 24, 2010

How to see output of hello world program in Dev-c++4 compiler?

How to see output printed on dos screen. ?


How to add watch, for debugging ?


Please help

How to see output of hello world program in Dev-c++4 compiler?
First things first. Use the line below, without the ' added, just above the last line of the program in the main function.


'system("PAUSE");'


I'm *ASSUMING* that you're using Windows, since what this commonly means is that you've hit run in the execute menu and get no output screen. What is really happening is that the program opens, outputs the message and closes the window so quickly that you don't see it happening. The system("pause"); statement passes the pause command to the operating system's command interpreter. Pause prints the infamous


"Press Any Key to Continue..." message and waits for a key to be pressed. So, this will hold the window open. Well, this works in C console or DOS programs under Windows. It is non-portable and won't necessarily work in other operating systems, so don't assume that it is a good practice at all times.





As to adding a watch for debugging, you likely won't be able to in DOS programs. This feature, if I'm right, is designed to work only with Windows GUI programs.





I hope this helps you out.


No comments:

Post a Comment