Главная страница | назад





Article #21588: Creating a Console Application (DOS style) in C++ Builder 5

Question:

How do I create and run an old DOS style Console Application in Borland C++ Builder 5?


Answer:
Creating a DOS Style Console Application in
Borland C++ Builder 5
You may use C++ Builder 5 to edit and compile DOS style
applications in addition to the Form based applications
that are the first line programs in Builder.
You cannot use the Form or its underlying text edit file
to create and compile a DOS style program. To compile this
type of program (DOS style), Follow these instructions:
1. Open Builder.
2. Click on "File" in the menu and follow the path:
File -> New -> Console Wizard.
3. In the Console Wizard Select C or C++ and Console App.
4. Click Finish.
You may enter and compile your code in the Text Edit
window that appears.

Example code:
#pragma hdrstop // Provided by compiler
#include <condefs.h> // Provided by compiler
#include <iostream.h>
#include <conio.h> // Contains getch() prototype
//---------------------------------------------------------
#pragma argsused // Provided by compiler
int main(int argc, char* argv[]) // Arguments provided by compiler
{
cout << "Hello World!" << endl;
getch(); // literally "GET CHaracter".
// This will hold the program at this
// point until a keystroke is entered
// so that the programmer may see
// the program output.
return 0;
}

Last Modified: 12-APR-00