A Little C Primer
This document is a quick introduction to the C programming language. It is written by a novice, and is intended for use by a novice. However, it does assume familiarity with a programming language.
The C programming language is a "middle-level" language. It provides low-level programming capability at the expense of some user-friendliness. Cynics tend to claim that C combines the flexibility and power of assembly language with the user-friendliness of high-level language, but experienced programmers find that the limited set of keywords and the use of pointers allows for fast and elegant programming solutions. C first rose to popularity with the growth of UNIX, and has been used creating the Windows operating system from its earliest versions. It is also used in microcontrollers and super-computers.
The original implementations of C were defined as described in the classic reference, THE C PROGRAMMING LANGUAGE, authored by Brian Kernighan and Dennis Ritchie. This definition left a few things to be desired, and the American National Standards Institute (ANSI) formed a group in the 1980s to create a complete specification. The result was "ANSI C", which is the focus of this document.
Tools For Programming[edit | edit source]
If you are new to programming then there are certain "tools" you need. The good news is that these tools are readily available for free and can be downloaded immediately. One of the major obstacles for beginners is the idea of using a compiler. A compiler is a program that takes your "code" (which is the technical term for the lines of programming language that you will write) and "compiles" it into an executable (every time you click an *.exe to install a program you are essentially running code that has been compiled and is ready to install or use on your computer).
When most people start to program in C, the first question they ask is along the lines of "Where are the windows that I see in MS Word?" It's only natural in a graphics dominated computer world to want to create a graphical interface for your program. The easiest way to write a Windows "style" program in C is by downloading Visual C++ (from Microsoft). This IDE (Integrated Development Environment) allows you to easily call Microsoft's GUI (Graphical User Interface) where all the buttons, windows, dialog boxes, etc are already designed and ready for use in your program. If you are just starting out then Microsoft provides a free version of Visual C++ with features and functionality that almost matches the professional version.
Though the programming examples given in this book are not GUI based you can still use Visual C++ to compile them. It's also a good idea to learn to create simple, command-line programs before moving on to GUIs. Please note that there are many free C and C++ compilers and coding tools offered by companies other than Microsoft. If you wish to try another IDE, forums and freeware sites are ideal places to find out about these.
Table of Contents[edit | edit source]
Introduction to C; Functions; Control Constructs[edit | edit source]
C Variables, Operators & Preprocessor Directives[edit | edit source]
C Input & Output[edit | edit source]
C Library Functions & Other Comments[edit | edit source]
- C Math Library
- C Standard Utility Library & Time Library
- The C sprintf Function
- C String Function Library
- C Character Class Test Library
- C Command Line Arguments
- Pointers to C Functions
- C Dynamic Memory Allocation & Deallocation
- Common Programming Problems in C