Things To Do
- Start the Borland C/C++ Builder 5 Program
- Choose File-New-Console Wizard. Choose the Console Wizard icon from the selection.
- Choose C (not C++) and click OK.
- You will get the following code in an edit window.
//---------------------------------------------------------------------------#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
return 0;
}
//---------------------------------------------------------------------------
- To produce the Hello World program, do the following.
- Add #include <stdio.h> just before the #pragma line.
- Add printf("Hello World\r\n"); in the main just before the return statement.
- Click Run-Run from the menu. You'll get a flash of a DOS window.
- To get the window to hold, do the following:
- Add #include <conio.h> after the stdio.h include.
- Add while(!kbhit()) { } before the return statement. That will hold the window until you hit a key.
- That's it! Hit Run-Run again to run the program.
There are some further things you can do to learn more about C and this environment. Here is a partial list.
- Check out what the "\r" and "\n" do in the program. They are escape sequences and they allow you to control position of the output. To check them out, add a second printf statement, and run the program with and without the escape sequences (or just take one of them out). Look at the results to be sure you understand what happens.
- Include some variables - after defining them - and do some calculations and print the results. Refresh you memory about format strings in the printf function.
Now, what if you want to use some of the programs that have been written for the instruments we have? Here's what you do.Finally, if you want to look at the Visual version of Hello World, click here.
- Click View-Project Manager. You will then see the Project Manager Window.
- To use functions previously written contained in a different file do the following.
- If your functions are in a file, like Hydra.c, you need to have Hydra.c in your project. Right click the executable in the Project Manager window, and go to Add. Then locate your c-file and add it to the project.
- If you use a set of functions like Hydra.c, there is also an include file that goes with it. You will need to add #include <Hydra.h> at the appropriate place in your program - i.e. at the beginning. Do not add Hydra.h to your project (see the previous step). If you do that, do not ask your instructor for help. You were warned.
- Click here for an example for the Hydra.