Tuesday, July 28, 2009

Problem with Borland Turbo C++ 1.0.1?

I'm new to C++ programming..I created a simple program which was suppose to print the words "Hello" to the screen, I compiled with Borland TurboC++ 1.0.1


- there were no compile errors


- The executable was also created


- but when I ran the executable A window popped up similar to that of a command prompt window %26amp; disappeard instanly.


- when I compiled the same source code with MS Visual c++ 2008 Express the program ran successfully and paused saying "press any key to continue".





What could be the problem? Please help me out...!





the source code(typed in Borland's %26amp; MS Visual's compiler):


======================================...





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


int main()


{


cout %26lt;%26lt; "hello\n";


return 0;


}

Problem with Borland Turbo C++ 1.0.1?
Try adding a





getch();





or





getchar();





Above the return line? Although I'm just guessing because I use C and not C++ sorry.
Reply:Visual C++ 2008 is a much more sophisticated development environment than Borland Turbo C++ 1.0.1 was. I suspect you ran it in Debug mode and it was smart enough to put in that pause for you.





The way to do that in Turbo C++ is to simply put in some console input statement (cin should even work) just before the program's exit point. In most cases, a console output message right before it is often nice to flag the input-needed situation.





Hope that helps.

pansy

No comments:

Post a Comment