QUESTION/DISCUSSION
1. How to
a. Compilation process.
There are also equivalent C++ compilers which are usually denoted by CC (note upper case CC. For example Sun provides CC and GNU GCC. The GNU compiler is also denoted by g++
Other (less common) C/C++ compilers exist. All the above compilers operate in essentially the same manner and share many common command line options. Below and in Appendix we list and give example uses many of the common compiler options. However, the best source of each compiler is through the online manual pages of your system: e.g. man cc.
For the sake of compactness in the basic discussions of compiler operation we will simply refer to the cc compiler -- other compilers can simply be substituted in place of cc unless otherwise stated.
To Compile your program simply invoke the command cc. The command must be followed by the name of the (C) program you wish to compile. A number of compiler options can be specified also. We will not concern ourselves with many of these options yet, some useful and often essential options are introduced below -- See Appendix or online manual help for further details.
Thus, the basic compilation command is:
cc program.c
where program.c is the name of the file.
If there are obvious errors in your program (such as mistypings, misspelling one of the key words or omitting a semi-colon), the compiler will detect and report them.
There may, of course, still be logical errors that the compiler cannot detect. You may be telling the computer to do the wrong operations.
When the compiler has successfully digested your program, the compiled version, or executable, is left in a file called a.out or if the compiler option -o is used : the file listed after the -o.
It is more convenient to use a -o and filename in the compilation as in
cc -o program program.c
which puts the compiled program into the file program (or any file you name following the "-o" argument) instead of putting it in the file a.out
b. Execute the program.
First of all the source code is get compiled and the object code is returned i.e.binary code(machine language).Then the linker is called.Linker, a computer program that takes one or more objects generated by a compiler and combines them into a single executable program.Now when the program is executed then the .exe file is first loaded into the memory and then executed by the processor.
In short the steps are: 1.Compilation
2.Linking
3.Loading
4.execution
2. What is C++ Programming
High-level programming language developed by Bjarne
Stroustrup at Bell
Labs. C++ adds object-oriented features to its
predecessor, C. C++ is one of the most popular programming languages for
graphical applications, such as those that run in Microsoft Windows and Apple Macintosh environments. C++ is named
after C's increment operator. Below is an example of a C++ program that prints
Hello World!.
#include <iostream>
int main()
{
std::cout << "Hello, world!\n";
}
int main()
{
std::cout << "Hello, world!\n";
}
Attention:
1. Insert the answer into your own Blog
CONCLUSION
Fron the C++ programm. I have learn how to know the complitation the process of a C++, and also know how to execute the program when using C++ to running the programm. That when using all that make me understand how to doing and completed work giving in individu.
0 comments:
Post a Comment