details on how to install Borland C++, please follow the instructions that come with the compiler.
I assume that you’ve installed a copy of Borland C++ 5.02 on your computer. To start the compiler, you can click the Start button from your Windows 95 (or Windows 98 or NT) task bar, and choose Programs, Borland C++ 5.02, Borland C++. Or, you can simply run the application file bcw.exe directly from the directory (folder) where you installed the Borland C++ package. Figure 1.8 shows an example of the integrated development environment (IDE) from Borland C++ 5.02.
Then, you can open a new file within the IDE, and type the following text in the space of the newly opened file:
#include
main()
{
printf (“Howdy, neighbor! This is my first C program.\n”);
return 0;
}
03 067231861x CH01 4.10.2000 10:59 AM Page 22
22
Hour 1
FIGURE 1.8
Creating a program
with the Borland C++
IDE.
Figure 1.9 shows the IDE with the text you just typed. Don’t worry about the meaning of the text. The next hour will explain it to you.
FIGURE 1.9
Saving C program text
with Borland’s IDE.
03 067231861x CH01 4.10.2000 10:59 AM Page 23
Taking the First Step
23
Now you need to save the text as a file. Let’s call the file MyFirstProgram.c. Note that the extension .c is used to indicate that the file you just saved is a C program file.
1
Now, you need to click the Project menu and choose the Compile option. By doing so, you ask the compiler to start compiling the text you just typed and saved. Figure 1.10
shows that there are no errors or warnings after MyFirstProgram.c is compiled and MyFirstProgram.exe is created.
FIGURE 1.10
Compiling a C pro-
gram using Borland’s
IDE.
You are now ready to run the executable file, MyFirstProgram.exe, that you just compiled. You can run it by clicking the Run button on the toolbar. Or, you can run MyFirstProgram.exe directly from the directory where you created it. Because the executable file is in fact a DOS application, a DOS prompt window will show up when the executable file is running (see Figure 1.11).
FIGURE 1.11
Running a C program
using Borland’s IDE.
03 067231861x CH01 4.10.2000 10:59 AM Page 24
24
Hour 1
Figure 1.11 displays the output exactly as you just typed it: “Howdy neighbor! This is my first C program.” This is indeed your first C program output!
If you want to learn more details on how to use Borland C++, read a book such as Teach Yourself Borland C++ 5 in 21 Days .
Here is a brief note on binary code and executable files. You’ll learn more details later in this book. Basically, before you can run a C program on your computer you need to use a C compiler to translate the C program into
machine-understandable code (that is, binary code). When the translation is done, the binary code can be saved into an application file. The binary code or application file is called executable code, or an executable file, because it can be executed directly on your computer.
Summary
In this first lesson you learned the following basic things about the C language:
• C is a general-purpose programming language.
• C is a high-level language that has the advantages of readability, maintainability, and portability.
• C is a very efficient language that allows you to control computer hardware and peripherals.
• C is a small language that you can easily learn in a relatively short time.
• Programs written in C can be reused.
• Programs written in C must be compiled and translated into machine-readable code before the computer can execute them.
• Many other programming languages, such as Perl, C++, and Java, have adopted basic concepts and useful features from the C language. Once you learn C, learning these other languages is much easier.
• The ANSI standard for C is the standard supported by C compiler vendors to maintain the portability of C programs.
• You can use any ANSI C compliant compiler to compile all of the C programs in
Bella Jewel
Andrea Barrett
Crais Robert
Mark R. Levin
Bobby Flay
Tia Louise
L.U. Ann
Trouble on Titan
Elaine Barbieri
Maddy Edwards