Let's C
Let’s start with a brief history of the C programming language.
The History of C
The C programming language was invented in the Bell Labs in 1969 as a by product of the UNIX operating system. It was developed by Dennis Ritchie and Ken Thompson as an easier way to code on the UNIX platform.
For further reading, read: History of C
King, K. N. (2008). C Programming: A Modern Approach (2nd ed.). New York, NY: W.W. Norton & Company.
C Fundamentals
Writing a simple program
/* Program letus.c */
#include <stdio.h>
int main(void)
{
printf("Let us C!\n");
return 0;
}
Filename: letus.c
Every C program follow a general form
directives
int main(void)
{
statements;
}
What are directives?
Before a C program is compiled, it is first edited by a program called a preprocessor. Commands intended for the preprocessor are called directives.
In the program letus.c
, it begins with the line:
#include <stdio.h>
This is a directive to the preprocessor to include the information found in the header <stdio.h>
in to the program letus.c
before it is compiler.
We will discuss headers more in-depth as we become more familiar with C.
<stdio.h>
is the header responsible for Standard Input and Output within the program. It enables us to use the standard function printf()
in our programs.
C has many headers like <stdio.h>
; each contain information about some functionality provided by the standard library.
Note: The C Standard library is a set of pre-compiled functionality that enables us to do regular functions without having to reinvent the wheel.