Format Type: PDF, Mobi
Read Online: 261
Introduction to C ProgrammingThis textbook was written with two primary objectives. The first is to introduce the C program-ming language. C is a practical and still-current software tool; it remains one of the most popular programming languages in existence, particularly in areas such as embedded systems. C facilitates writing code that is very efficient and powerful and, given the ubiquity of C compilers, can be easily ported to many different platforms. Also, there is an enormous code-base of C programs developed over the last 30 years, and many systems that will need to be maintained and extended for manyyears to come.The second key objective is to introduce the basic concepts of software design. At one-level thisis C-specific: to learn to design, code and debug complete C programs. At another level, it is moregeneral: to learn the necessary skills to design large and complex software systems. This involves learning to decompose large problems into manageable systems of modules; to use modularity andclean interfaces to design for correctness, clarity and flexibility.C is a general-purpose programming language, and is used for writing programs in many differ-ent domains, such as operating systems, numerical computing, graphical applications, etc. It is asmall language, with just 32 keywords (see [HS95, page 23]). It provides "high-level" structured-programming constructs such as statement grouping, decision making, and looping, as well as "low-level" capabilities such as the ability to manipulate bytes and addresses.Since C is relatively small, it can be described in a small space, and learned quickly. Aprogrammer can reasonably expect to know and understand and indeed regularly use theentire language [KR88, page 2].C achieves its compact size by providing spartan services within the language proper, foregoingmany of the higher-level features commonly built-in to other languages. For example, C providesno operations to deal directly with composite objects such as lists or arrays. There are no memorymanagement facilities apart from static definition and stack-allocation of local variables. And thereare no input/output facilities, such as for printing to the screen or writing to a file.Much of the functionality of C is provided by way of software routines calledfunctions.Thelanguage is accompanied by astandard libraryof functions that provide a collection of commonly-used operations. For example, the standard functionprintf()prints text to the screen (or, moreprecisely, tostandard output-which is typically the screen). The standard library will be usedextensively throughout this text; it is important to avoid writing your own code when a correct andportable implementation already exists.