community.borland.com

Article #20621: How do I create a "Hello World" DOS console application using C++Builder?

Question: How do I create a "Hello World" DOS console application using C++Builder? I have used other Borland compilers to do this, but the code does not seem to work with C++Builder.

Answer: The first step is to bring up a text-edit window using the Console Wizard. Detailed instructions can be in the following FAQ:
http://community.borland.com/article/0,1410,19442,00.html

To bring up the text-edit window you need:

  1. File | Close All
  2. File | New | Console Wizard...

Choose the options you want and press Enter. For example, in Borland C++Builder 5 one might uncheck "Use VCL" and choose to specify the source for the project.

The window will open with source code that looks very similar to what is shown below:

//---------------------
#include
#pragma hdrstop
//---------------------
#pragma argsused
int main(int argc, char* argv[])
\{
return 0;
\}
//---------------------

Modify the code so it looks like the following:

//---------------------
#include //needed for input/output #include //function getch(): used to keep the window on the screen #include
#pragma hdrstop
//---------------------
int main(void)
\{
cout<<"Hello World!"; //prints text to the screen getch(); //keeps the window on the screen return 0;
\}
//---------------------

When you have finished typing in the code and checking it for errors, press F9 or single click the green arrow on the toolbar to compile and run your application.

Last Modified: 28-MAR-00