Friday, July 31, 2009

Please help me with DEV-C++?

I am a beginner in C++ programming and I chose to program in Dev-C++ which was a free software I followed the instructions from a tutorial and this is the program I wrote:





#include %26lt;iostream.h%26gt;





int main() {





//print out the text string, "Hello, World!"


cout %26lt;%26lt; "Hello, World!" %26lt;%26lt; endl;





return 0;





}


but when I try to compile and run the program my output console just flashes for one instant and it is gone,


I cannot see the program


what should I do?

Please help me with DEV-C++?
The problem with console programming is you either have to run it from a console or you have to do a workaround. I don't know what version of Windoze you are using, obviously. If it's XP or earlier, open the console by going to Run on the start menu, typing "command", and changing your directory to the programs you want to run.





An easier way is to add to your programs :





system("PAUSE");





before return 0. System() calls an external program. It is actually found in stdlib.h which is called by stdio.h, which is called by iostream.h. You can #include stdlib.h (or cstdlib in more uptodate syntax) or not. Pause is an MS-Dos program which pauses operation, writes "Press any key" to the window, and waits till you do to terminate. Some people use the conio.h library for this but some people don't like to think.
Reply:You should pause your program before it exits so you can see the output.





Just insert a system("pause"); before the return.

dried flowers

No comments:

Post a Comment