C
C is a general-purpose programming language. It was created in the 1970s by Dennis Ritchie and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems code (especially in kernels), device drivers, and protocol stacks, but its use in application software has been decreasing. C is commonly used on computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems.
C is an imperative procedural language, supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support. Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant C program written with portability in mind can be compiled for a wide variety of computer platforms and operating systems with few changes to its source code.
It has a static type system. In C, all executable code is contained within subroutines (also called "functions", though not in the sense of functional programming). Function parameters are passed by value, although arrays are passed as pointers, i.e. the address of the first item in the array. Pass-by-reference is simulated in C by explicitly passing pointers to the thing being referenced.
C program source text is free-form code. Semicolons terminate statements, while curly braces are used to group statements into blocks.
I first ran into C in college. While working as a computer lab assistant, I ran across a DECUS tape that had a C compiler that would reportedly run under RSTS/E’s RSX subsystem. I got permission to load the tape and copy off the compiler sources and makefile. The compiler was written in Macro-11 and while it compiled it did not generate runable code. A two week journey into the code and I discovered that a piece ot the code generator was producing malformed assembler. Correcting the problem got me extra credit in my compiler class.
I would run into C again and again in various Unix systems over the years. Including CP/M, MS-DOS, Windows, Unix and Linux. Even now I am still writing C and C++ applications.
Sample Code
This sample program like the others is also a looped version of the classic Hello World program. We will be using Manx Software System’s Aztec C compiler. This compiler is fairly faithful to the original K&R C. Later HiTech C will come along and be more Ansi compliant.
E>type hello.c
main()
{
int i;
for( i = 1; i <= 10; i++ ) {
printf("Hello World, from Aztec C line %d\n", i);
}
}
E>cz hello
C Vers. 1.06D Z80 (C) 1982 1983 1984 by Manx Software Systems
E>as hello
8080 Assembler Vers. 1.06D
D>ln hello.o -lc
C Linker Vers. 1.06D
Base: 0100 Code: 1ff0 Data: 01f8 Udata: 0362 Total: 00254e
E>hello
Hello World, from Aztec C line 1
Hello World, from Aztec C line 2
Hello World, from Aztec C line 3
Hello World, from Aztec C line 4
Hello World, from Aztec C line 5
Hello World, from Aztec C line 6
Hello World, from Aztec C line 7
Hello World, from Aztec C line 8
Hello World, from Aztec C line 9
Hello World, from Aztec C line 10
E>
Comments