Hardware Reference
In-Depth Information
7 C and C++ programming
The C programming language was the brainchild of Dennis Ritchie and the
language was originally implemented on a DEC PDP-11 running under the
UNIX operating system. Despite its origins and close association with UNIX, C,
and its latest incarnation, C ++ , is now available in a variety of implementations.
These include the immensely popular Borland C ++ and Microsoft Visual C.
The C language is comparatively small but it employs a powerful range of
control flow and data structures. It is, therefore, not surprising that it has become
increasingly popular amongst programmers and software engineers. The lan-
guage is well suited to the development of effective real-time applications aid
is ideally suited to the world of control and instrumentation (C is an excellent
choice for small, tight, and fast applications).
The relatively small core of the language has been instrumental in ensuring a
high degree of portability from one hardware configuration to another. C offers
some significant advantages in the development of software for real-time appli-
cations. The language, which promotes the use of structure, is highly portable
and it yields code that is relatively compact. Furthermore, when compiled, it can
offer execution speeds which are far in excess of those which can be obtained
with comparable interpreted languages.
To the newcomer, C and C ++ source code can appear somewhat cryptic.
Indeed, programmers experienced in other (less structured) languages may have
difficulty when making the transition to C. Indeed, it is often said that it is easier
to learn C if one has not had the misfortune of acquiring preconceptions devel-
oped as a result of a familiarity with BASIC:. Whilst this may be demonstrably
true, the fact is that most of today's learners of C and C ++ will already be
proficient in one or more other languages and these will invariably include
BASIC.
Those wishing to develop proficiency with C/C ++ programming should not
underestimate the amount of time required. As always, the best way to learn
is to test out each new concept as it is introduced. Furthermore, it is best not
to dwell on comparisons between C and other languages (such as BASIC).
It is first necessary to understand something of the structure of C programs
before progressing to such topics as data types, pointers, functions, and control
structures. The rewards for perseverance are considerable!
The code fragments and complete examples given in this chapter have been
written using several different C/C ++ compilers but those written using the
Borland C ++ 4.5 are based on ANSI C and will work with any C compiler.
Provided that an effective Integrated Development Environment (IDE) is avail-
able, program development in C/C ++ is simple and straightforward and the
process of entering code, compiling, and linking is fully automated.
Figures 7.1-7.4 show examples of four different IDEs for use with C/C ++
compilers.
Search WWH ::




Custom Search