29-11-2012, 04:40 PM
C++: The Complete Reference Third Edition
1C++ The Complete Reference.pdf (Size: 8.77 MB / Downloads: 124)
The Origins of C
C was invented and first implemented by Dennis Ritchie on a DEC PDP-11 that used
the Unix operating system. C is the result of a development process that started with an
older language called BCPL. BCPL was developed by Martin Richards, and it
influenced a language called B, which was invented by Ken Thompson. B led to the
development of C in the 1970s.
For many years, the de facto standard for C was the version supplied with the Unix
version 5 operating system. It was first described in The C Programming Language by
Brian Kernighan and Dennis Ritchie (Englewood Cliffs, N.J.: Prentice-Hall, 1978). In the
summer of 1983 a committee was established to create an ANSI (American National
Standards Institute) standard that would define the C language once and for all. The
standardization process took six years (much longer than anyone reasonably expected).
The ANSI C standard was finally adopted in December 1989, with the first copies
becoming available in early 1990. The standard was also adopted by ISO (International
Standards Organization) and is now referred to as the ANSI/ISO C standard. For
simplicity, this book will use the term Standard C when referring to the ANSI/ISO C
standard. Today, all mainstream C/C++ compilers comply with Standard C. Standard
C is the foundation upon which C++ is built.
C Is a Middle-Level Language
C is often called a middle-level computer language. This does not mean that C is less
powerful, harder to use, or less developed than a high-level language such as BASIC
or Pascal, nor does it imply that C has the cumbersome nature of assembly language
(and its associated troubles). Rather, C is thought of as a middle-level language because
it combines the best elements of high-level languages with the control and flexibilityof
assembly language. Table 1-1 shows how C fits into the spectrum of computer
languages.
As a middle-level language, C allows the manipulation of bits, bytes, and
addresses—the basic elements with which the computer functions. Despite this fact
C code is also very portable. Portability means that it is easy to adapt software written
for one type of computer or operating system to another. For example, if you can easily
convert a program written for DOS so that it runs under Windows, that program is
portable.
C Is a Structured Language
In your previous programming experience, you may have heard the term blockstructured
applied to a computer language. Although the term block-structured
language does not strictly apply to C, C is commonly referred to simply as a
structured language. It has many similarities to other structured languages, such
as ALGOL, Pascal, and Modula-2.
The reason that C (and C++) is not, technically, a block-structured language is that
block-structured languages permit procedures or functions to be declared inside
other procedures or functions. Since C does not allow the creation of functions
within functions, it cannot formally be called block-structured.
The distinguishing feature of a structured language is compartmentalization of code
and data. This is the ability of a language to section off and hide from the rest of the
program all information and instructions necessary to perform a specific task. One
way that you achieve compartmentalization is by using subroutines that employ local
(temporary) variables. By using local variables, you can write subroutines so that the
events that occur within them cause no side effects in other parts of the program. This
capability makes it very easy for programs to share sections of code. If you develop
compartmentalized functions, you only need to know what a function does, not how it
does it. Remember, excessive use of global variables (variables known throughout the
entire program) may allow bugs to creep into a program by allowing unwanted side
effects. (Anyone who has programmed in standard BASIC is well aware of this
problem.)
C Is a Programmer's Language
Surprisingly, not all computer programming languages are for programmers. Consider
the classic examples of nonprogrammer languages, COBOL and BASIC. COBOL was
designed not to better the programmer's lot, nor to improve the reliability of the code
produced, nor even to improve the speed with which code can be written. Rather,
COBOL was designed, in part, to enable nonprogrammers to read and presumably
(however unlikely) to understand the program. BASIC was created essentially to allow
nonprogrammers to program a computer to solve relatively simple problems.
In contrast, C was created, influenced, and field-tested by working programmers.
The end result is that C gives the programmer what the programmer wants: few
restrictions, few complaints, block structures, stand-alone functions, and a compact
set of keywords. By using C, you can nearly achieve the efficiency of assembly code
combined with the structure of ALGOL or Modula-2. It's no wonder that C and C++
are easily the most popular languages among topflight professional programmers.