Learning the C Programming Language
C programming manuals and tutorials
Mosaic's single board computers are programmable in either the C or Forth programming languages. There are many C programming books and tutorials available both online and on paper. We recommend the following references for novice C programmers. You can download some of these books in pdf form directly from the links on this page; others are available from you favorite bookseller. Most of these resources are focused solely on the C language. For assistance in C programming in the context of real time applications and a real time multitasking operating system consult the specific documentation for the Mosaic IDE and Mosaic IDE Plus.
TutorialsPoint C Tutorial
TutorialsPoint Online C Tutorial (interactive online version)
TutorialsPoint Printed C Tutorial (download pdf version)
This tutorial is a quick, easy and fairly concise, interactive online tutorial for learning the syntax of the C language. The online version allows you to immediately compile code fragments to see their behavior, and the pdf version is easily read on your desktop, cell phone or tablet.
This interactive online tutorial is particularly engaging for novice programmers of all ages.
The C Programming Language, 2nd Edition, by Kernighan and Ritchie
The C Programming Language 2nd Ed by Kernighan and Ritchie (a compressed 792 KB pdf)
Or, download a larger 20 MB pdf of The C Programming Language, 2nd Edition, by Kernighan and Ritchie, from any of these sites:
If there is a C bible, this is it. Kernighan and Ritchie's short book is a concise guide to ANSI standard C. Written by the developers of C, this simple guide teaches you the ANSI standard for C while giving sufficient attention to C's rich set of operators, economy of expression, improved control flow, and data structures. The book assumes you're already familiar with basic programming concepts like variables, assignment statements, loops, and functions. Even a novice programmer should be able to read along and pick up the language. For years, C programmers have let K&R guide them to building well-structured and efficient programs. For a good review of this book, consult the Wikipedia article.
C Programming Tutorial (K&R version 4), by Mark Burgess
C Programming Tutorial (online html)
C Programming Tutorial (pdf)
This book is a tutorial for beginners, but with enough detail so as not to be outgrown as the years go by. The author presumes that you have some previous aquaintance with programming — you need to know what a variable is and what a function is — but you do not need much experience.
It is not essential to follow the order of the chapters rigorously, but if you are a beginner to C it is recommended.
Every program is limited by the language which is used to write it. C is a programmer's language. Unlike BASIC or Pascal, C was not written as a teaching aid, but as an implementation language. C is a computer language and a programming tool which has grown popular because programmers like it! It is a tricky language but a masterful one. Sceptics have said that it is a language in which everything which can go wrong does go wrong. True, it does not do much hand holding, but also it does not hold anything back. If you have come to C in the hope of finding a powerful language for writing everyday computer programs, then you will not be disappointed. C is ideally suited to modern computers and modern programming.
This book is a tutorial. Its aim is to teach C to a beginner, but with enough of the details so as not be outgrown as the years go by. It presumes that you have some previous aquaintance with programming – you need to know what a variable is and what a function is – but you do not need much experience. It is not essential to follow the order of the chapters rigorously, but if you are a beginner to C it is recommended. When it comes down to it, most languages have basically the same kinds of features: variables, ways of making loops, ways of making decisions, ways of accessing files etc. If you want to plan your assault on C, think about what you already know about programming and what you expect to look for in C. You will most likely find all of those things and more, as you work though the chapters.
The examples programs range from quick one-function programs, which do no more than illustrate the sole use of one simple feature, to complete application examples occupying several pages. In places these examples make use of features before they have properly been explained. These programs serve as a taster of what is to come.
Beginning C, 5th Edition, by Ivor Horton
Beginning C (pdf) (5.9 MB, 688 pages)
Beginning C, 5th Edition teaches you how to program using the widely-available C language. You'll begin from first-principles and progress through step-by-step examples to become a competent, C-language programmer. All you need are this book and any of the widely available free or commercial C or C++ compilers, and you'll soon be writing real C programs.
Beginning C is written by renowned author Ivor Horton. The book increases your programming expertise by guiding you through the development of fully working C applications that use what you've learned in a practical context.
C in a Nutshell
C in a Nutshell (at Amazon.com)
Learning a language involves a process wherein you learn to rely less and less on instruction and more increasingly on the aspects of the language you've mastered. Whether you're learning French, Java, or C, at some point you'll set aside the tutorial and attempt to converse on your own. It's not necessary to know every subtle facet of French in order to speak it well, especially if there's a good dictionary available. Likewise, C programmers don't need to memorize every detail of C in order to write good programs. What they need instead is a reliable, comprehensive reference that they can keep nearby. C in a Nutshell is that reference.
Understanding and Using C Pointers, Core techniques for memory management
Understanding and Using C Pointers (at Amazon.com)
Improve your programming through a solid understanding of C pointers and memory management. With this practical book, you'll learn how pointers provide the mechanism to dynamically manipulate memory, enhance support for data structures, and enable access to hardware. Author Richard Reese shows you how to use pointers with arrays, strings, structures, and functions, using memory models throughout the book.
Difficult to master, pointers provide C with much flexibility and power - yet few resources are dedicated to this data type. This comprehensive book has the information you need, whether you're a beginner or an experienced C or C++ programmer or developer.
An Introduction to GCC, by Brian J. Gough, foreword by Richard M. Stallman
Introduction to GCC (online html)
Introduction to GCC (pdf) (124 pages)
The purpose of this book is to explain the use of the GNU C and C++ compilers, gcc and g++. After reading this book you should understand how to compile a program, and how to use basic compiler options for optimization and debugging. This book does not attempt to teach the C or C++ languages themselves, since this material can be found in many other places.
The original author of the GNU C Compiler (GCC) is Richard Stallman, the founder of the GNU Project.
The GNU project was started in 1984 to create a complete Unix-like operating system as free software, in order to promote freedom and cooperation among computer users and programmers. Every Unix-like operating system needs a C compiler, and as there were no free compilers in existence at that time, the GNU Project had to develop one from scratch. The work was funded by donations from individuals and companies to the Free Software Foundation, a non-profit organization set up to support the work of the GNU Project.
The first release of GCC was made in 1987. This was a significant breakthrough, being the first portable ANSI C optimizing compiler released as free software. Since that time GCC has become one of the most important tools in the development of free software.
21st Century C, C Tips from the New School
21st Century C (at Amazon.com)
Throw out your old ideas of C, and relearn a programming language that's substantially outgrown its origins. With 21st Century C, you'll discover up-to-date techniques that are absent from every other C text available. C isn't just the foundation of modern programming languages, it is a modern language, ideal for writing efficient, state-of-the-art applications. Learn to dump old habits that made sense on mainframes, and pick up the tools you need to use this evolved and aggressively simple language. No matter what programming language you currently champion, you'll agree that C rocks.
Head First C
Head First C (Kindle or paperback from Amazon.com)
Ever wished you could learn C from a book? Head First C provides a complete learning experience for C and structured imperative programming. With a unique method that goes beyond syntax and how-to manuals, this guide not only teaches you the language, it helps you understand how to be a great programmer. You'll learn key areas such as language basics, pointers and pointer arithmetic, and dynamic memory management. Advanced topics include multi-threading and network programming - topics typically covered on a college-level course.
We think your time is too valuable to waste struggling with new concepts. Using the latest research in cognitive science and learning theory to craft a multi-sensory learning experience, Head First C uses a visually rich format designed for the way your brain works, not a text-heavy approach that puts you to sleep.
Learning GNU C, by Ciaran O'Riordan
Learning GNU C (online html)
Learning GNU C (pdf)
The aim of this book is to teach GNU users how to write software in C. The aim of this project is to produce a free C programming tutorial book with a very practical focus. By practical, I mean it should help people to start writing their own software and getting involved in existing free software projects. It is written primarily as a tutorial for beginners but should be thorough enough to be used as a reference by experience programmers. The basics are layed down in full in the first few chapters, beginners will read these chapters carefully while those with prior experience can skim through them. All the information is there, no prior knowledge of programming is assumed.
The contents of this book can be divided into two topics: the core C language, and the standard functionality made available to the programmer. The standard functionality is provided by GNU Libc, this is a library of C functionality that is part of every GNU system. Neither of these topics is of much use without the other but there is a focus on the core langauge near the beginning and more discussion on Libc near the end. The ordering of topics is designed to teach C programming in an incremental fashion where each chapter builds on the previous one. Some aspects of the core langauge are only really of use to experienced programmers and so appear near the end.
The GNU C compiler for the 68HC11/68HC12/9S12/HCS12 microcontrollers
The Mosaic IDE for the QCard incorporates a proprietary C compiler, while the Mosaic IDE Plus for the PDQ Board launches the GNU C (GCC) compiler, an open source ANSI C standard compiler ported to the Freescale 9S12/HCS12 microcontroller. The Mosaic IDE Plus compiles C software programs using the GNU Development Chain for the 68HC11 & 68HC12. Customized device drivers are provided to speed the development of your software application.
For details of the GNU C implementation you can consult the following references:
- GNU C Reference Manual (online html)
- GNU C Library Functions (online html)
- GNU C Library Functions (pdf)
Other free C programming books and tutorials
For other C language books and tutorials consult this compendium of C language learning materials.
Another useful resource is the following C reference manual:
- C: A Reference Manual, 5th Edition, by Harbison and Steel
- and this online tutorial: Introduction to C Programming
Best practices for real-time embedded systems
Here is a page with links to resources for best practices and coding standards for time-constrained embedded systems.