History of C

C is a general-purpose programming language developed at Bell Laboratories by Ken Thompson, Denis Ritchie and others for the Unix operating system. C succeeded from a language named “B” developed by Thompson around the mid-1960.

The Unix operating system and virtually all Unix applications are written in the C language. However, C is not limited to a particular platform and programs can be created on any machine that supports C, including those running the Windows platform.

C is a popular language and has the following features:

  • Extremely Portable
  • Small and fast executables for system codes written in C
  • Simplicity and power
  • Low-level language
  • Block oriented language
  • Strongly typed

C is the bases of many modern languages such as C++, JAVA, Perl, Javascript, PHP, Python etc. Standard versions of C include K&R C, ANSI C (C89/C90), C99 and C11 being the latest standardized version. The codes presented in various exercises on this site uses c11 standard.

 

Sample C Program

Below is a simple c program which prints “Welcome to our online tutorials.” to the standard output.(filename: welcome.c)

#include <stdio.h>
int main(void) {
    printf("Welcome to our online tutorials.\n");
    return 0;
}
  • #include <stdio.h> is necessary to include information about C's standard I/O (input/output) library.
  • main (void){} represents the “main” program.
  • The line inside main is the command to display the desired message
  • printf is a function in the standard I/O library that can produce nicely formatted output.
  • The \n escape sequence tells printf to advance to the next line after printing the message.
  • The line return 0; indicates that the program “returns” the value 0 to the operating system when it terminates.

NB: The filename of every C source file must end with .c

 

Compilation Process

The C's program compilation process undergoes four separate stages, which each generate a new file:
Preprocessing - the preprocessor substitutes all preprocessor directives in the original source code .c file with actual library code that implements those directives. For instance, library code is substituted for #include directives. The generated file containing the substitutions is in text format and typically has a .i file extension.

Translating - the compiler translates the high-level instructions in the .i file into low-level assembly language instructions. The generated file containing the translation is in text format and typically has a .s file extension.

Assembling - the assembler converts the Assembly language instructions in the .s file into machine code. The generated object file containing the conversion is in binary format and typically has a .o file extension.

Linking – the linker combines one or more binary objects .o files into a single executable file. The generated file is in binary format and typically has a .exe file extension.

 

References

  • The C Programming Language (2th edition); K & R; Prentice Hall
  • C Programming- A Modern Approach (2th edition); K. N. KING;
  • C Programming in Easy Steps, Mike McGrath; 10: 9781840783636

Additional Resources

Listed below are some websites that you can visit to gain more knowledge: