K&R C vs C89/C90 ANSI
What you'll learn: You will understand how the transition from the original "Wild West" C to the first formal standard introduced stricter rules for defining and checking functions.
The Wild West: K&R C
In the late 1970s, Brian Kernighan and Dennis Ritchie published The C Programming Language. This version, known as K&R C, was the informal law of the land. It was flexible but dangerous. Imagine a restaurant where you can order "the usual" without the waiter knowing what that is until the plate actually arrives.
In K&R C, you didn't have to tell the compiler what arguments a function took before you called it. If you made a mistake—like passing a decimal number to a function expecting a whole number—the compiler often stayed silent, leading to mysterious crashes during the "meal" (runtime).
The Sheriff Arrives: ANSI C (C89/C90)
As C grew in popularity, developers needed a formal rulebook to ensure code worked the same way on every computer. In 1989, the American National Standards Institute (ANSI) released C89 (later adopted by ISO as C90).
The biggest change was the function prototype. Instead of guessing, you now had to explicitly tell the compiler: "This function exists, it returns an integer, and it requires exactly two integers as input." This allowed the compiler to catch your mistakes immediately while building the program.
Side-by-Side Comparison
Notice how the old style defines the types after the parentheses, whereas the new style looks like the C you likely use today.
/* K&R Style (Obsolete) */
int power(base, n)
int base;
int n;
{
// Function body here
}
/* C89/C90 Style (Modern Standard) */
int power(int base, int n)
{
// Function body here
}
By moving the types inside the parentheses, C89 introduced "Function Prototyping." This single change acted like a safety net, ensuring that every time you called a function, the data you passed in was the correct size and type for the memory waiting to receive it.
Key takeaway
C89 turned C from an informal language into a standardized one by introducing prototypes, which allow the compiler to verify that your function calls match their definitions.