The C Programming Language

Or rather, a guide written by someone who shouldn't be writing programming guides to the C programming language.


Introduction

This is an attempt at writing an introductory guide to the C programming language written by a lazy hobbyist that has been studying it for more than a decade.

Expect no textbook-level formality, this is a project written by me, for myself. If it happens to help someone out there, it's a bonus.

No prior knowledge of programming is required, but basic computing skills are helpful. You should be able to:

And that's pretty much it. Not much else will be needed.

What is a Programming Language?

You've probably seen code in your life at some point. That arcane combination of letters, numbers and characters that, for some godforsaken reason, orders your computer to do something.

Almost every single thing in your computer is a program, or is used by a program. Your operating system (be it some Linux distribution, FreeBSD, Windows, MacOS) is, by definition, a program.

A programming language is a way of communicating with your computer, and letting it know what you want it to do for you. Naturally, writing plain text English isn't enough to tell a computer what to do.

Let us delve into our first example. Imagine you are a machine that makes sandwiches. Your entire life purpose is making sandwiches whenever prompted to. Naturally, you're handed a list of things you must do sequentially in order to make a good sandwich, such as:

  1. Get one slice of bread.
  2. Spread peanut butter over that slice of bread.
  3. Get another slice of bread.
  4. Spread jelly over the second slice of bread.
  5. Join both slices with the fillings inside.
  6. Deliver your sandwich.

That is exactly what a program is. Except usual programs aren't written using plain English text. FUCK YOU, VIBECODERS.

Instead, we use a standardized language to tell our computer exactly what to do and in which order.

Computers often speak a language called machine code, which is, quite literally, just a bunch of ones and zeroes only a computer can quite understand. Some very weird humans can also understand it, but I digress.

When programming started, we used to "speak" the computer's language, giving it instructions sequentially in its own language. Eventually, we figured out it would be a whole lot easier if we developed a language that would be understandable by humans (and easy to write) instead of memorizing dozens of machine code instructions. This language could then be "translated" to machine code, which a computer could understand.

One of the most important languages of all time is but C itself! The jewel of computing. Old but gold.


#include 
int main()
{
    printf("Hello, world!\n");
    return 0;
}

Why C?

You might ask; "Why should I learn C?" or "Isn't C a dead language?", and those are all valid questions. C was the first language I studied, and has been my favourite ever since. Despite having tried many other languages, such as C++, Java, Haskell, C#, Rust and Python, C has remained my favourite one for a couple of reasons:

What I mean by those three main points is; C is not a language with a hundred different syntax gimmicks and functions nobody really needs or uses you should master in order to write good code. C is about as fast as fast goes, and C is most certainly not going to hold your hand and tidy up after your mess when you fuck up. C does exactly as told, no more, no less. If your program is shit, you're the one that messed up.

Why do all these points matter? To put it simply, you'll write quick, simple code, and will be forced not to mess up. Sounds good? Good.


First Steps

Now let's get our hands dirty. In order to write C programs, we're going to need a C compiler and a text editor. Yeah, that simple. Naturally, you might wonder what in the world is a compiler. Remember some paragraphs ago where I mentioned we made programs to transform programming languages into machine code? That's the compiler. The age-old example of the cake, the recipe and the bakery is a good way of understanding what the program, the source code and the compiler is.

Imagine you write a recipe (source code) for a cake (program). You then send that recipe to the bakery (compiler) which is going to give you back the finished cake (program).

There are a number of C compilers available for free.

Operating System Recommended Compiler
Linux Distribution GCC or Clang
MacOS Clang
Windows Mingw-w64

And if you're such a nerd that your operating system isn't on the table, I reckon you're more than able of looking one up yourself. Shout out to the 12 HaikuOS, ReactOS, Plan9 or KolibriOS active users out there somewhere.

You should download and install a compiler. I will, for the sake of my own sanity, assume you're using some Linux distribution and not Windows.


Real First Steps

To Be Continued... [09/04/2025]