C
In short
C is a compiled, low-level programming language that gives direct control over memory and is used to build operating systems, drivers, and embedded software.
What is the C programming language?
C is a general-purpose programming language created by Dennis Ritchie at Bell Labs in the early 1970s, originally to write the Unix operating system. It is small, fast, and close to the hardware: C code maps fairly directly onto machine instructions, which is why it is sometimes called a "portable assembly language." The language is standardized by ISO, and the latest standard is C23.
C is statically typed, but it trusts the programmer: values can be converted between types implicitly, and pointers (variables that hold memory addresses) can be cast freely. Memory is managed manually. Local variables live on the stack and disappear when a function returns, while longer-lived data is requested from the heap with malloc and must be handed back with free. There is no garbage collector and no bounds checking on arrays, so mistakes can cause memory leaks, crashes, or security holes such as buffer overflows.
C is used for operating system kernels such as Linux, embedded firmware in microcontrollers, device drivers, databases, and the interpreters of other languages, including CPython. Because almost every language can call C functions, C also acts as a common meeting point between languages. Writing C is a bit like driving a manual car with no driver assistance: you control everything, but every gear change is your responsibility.
C is often lumped together with C++, but they are different languages. C++ began as an extension of C and can compile most C code, yet it adds classes, templates, exceptions, and a much larger standard library. C stays deliberately minimal: it has no classes, no exceptions, and no built-in string type, since strings are simply arrays of characters ending with a zero byte.
Key takeaways
- C compiles directly to machine code, which makes it fast and predictable.
- Memory is managed manually with functions like
mallocandfree. - It has no classes, exceptions, or garbage collector.
- Operating system kernels, embedded firmware, and many language runtimes are written in C.
Example
#include <stdio.h>
#include <stdlib.h>
int main(void) {
// Ask the heap for space for 5 integers
int *numbers = malloc(5 * sizeof(int));
if (numbers == NULL) return 1;
for (int i = 0; i < 5; i++) numbers[i] = i * i;
printf("Last square: %d\n", numbers[4]);
free(numbers); // C never frees memory for you
return 0;
}Readers ask
Is C still used today?
Yes. C is still a core language for operating systems, embedded devices, and performance-critical libraries, and many higher-level languages rely on components written in C.
What is the difference between C and C++?
C++ grew out of C and adds features such as classes, templates, exceptions, and a large standard library. C is smaller and simpler, and is often chosen where minimal runtime overhead and easy portability matter most.
Why is C considered unsafe?
C does not check array bounds or track memory for you, so bugs like reading past the end of a buffer or using memory after freeing it can crash a program or create security holes. Careful coding, sanitizer tools, and code review help reduce these risks.
Often compared
See also
- C++Programming Languages, p. 5C++ is a compiled, statically typed language that extends C with classes and templates while keeping low-level control over memory and performance.
- CompilerProgramming Fundamentals, p. 11A compiler is a program that translates source code written in a programming language into a lower-level form, such as machine code, that a computer can run.
- Memory LeakOperating Systems, p. 19A memory leak is a bug where a program keeps holding memory it no longer needs, so its memory usage grows over time and can slow down or crash the system.
- KernelOperating Systems, p. 17A kernel is the core part of an operating system that manages the CPU, memory, and hardware devices and controls how programs get access to those resources.
- RustProgramming Languages, p. 29Rust is a compiled, statically typed systems language that provides memory safety without a garbage collector by checking ownership rules at compile time.
- LinuxDevOps & Cloud, p. 33Linux is an open-source operating system kernel that powers most servers, cloud platforms, containers, and Android phones, usually packaged as a distribution.
- ZigProgramming Languages, p. 33Zig is a low-level systems programming language that aims to be a simpler, safer successor to C, with manual memory management and no hidden control flow.
- Objective-CProgramming Languages, p. 21Objective-C is an object-oriented superset of C with Smalltalk-style messaging, and it was the main language for macOS and iOS apps before Swift arrived.
Spotted a mistake or something missing on this page?Suggest an edit