|
From: Adam J. <aj...@i-...> - 2007-07-14 01:44:10
|
>>There are two global solutions:
>>a. make your program wait for a keypress before exiting
>>b. open a console, go to the folder, and run the program from there.
There is a third choice and that is to use the system("pause") it is very
easy to use and very appropriate for what he is doing in the Hello world
program. He must make sure that he includes the <cstdlib> header.
>>a. is is easier for you to use while developping, since you can start the
prog from DevC++ and see the result.
>>A correct way of doing this is to call getchar();
>>this will try to read a char from the input, and will wait until it gets
one. much better.
>An EVIL way is to call system("pause"); You can read why here:
http://www.gidnetwork.com/b-61.html
I read this link along with others that this person posted. Having a
system("pause") call at the end of the program poses no problem, because the
next call is to exit. Especially in a HELLO WORLD program. Using
system("pause") in a release version would not make sense. Using
system("pause") to stop execution to aid in debugging an application makes a
lot of since. Especially if you choose not to use gdb to debug your code.
It is in the language for a reason. Use it when it is appropriate.
>>Jonathan
>>On 7/13/07, arpit jain <arp...@gm...> wrote:
>>im new 2 programing & i have been trying to learn C, & for that i started
using bloodshed dev c++5.0 but what im not getting is when i run the program
the software doesnt show >>the result but makes an application file (DOS
based) for e.g. that HELLO WORLD program's output just gets flashed in the
command prompt which im myself unable to see properly >>as it flashes
hardly even for a second. could u pls. help me on this.........????
Jonathan my advice to you is to understand how to use the language
efficiently. You will find people telling you never to program this way or
never to program that way. But they make a religion out of it. I have
confidence in the designers who developed C\C++, and the ANSI community that
oversees the ANSI standard for C\C++. You use what is best for the problem
you are trying to solve. Every keyword/STL function, etc has it's pros and
cons. You need to understand what those are and program accordingly.
-Adam Jones
|