How To Program Anything: C Programming

This is part of a larger series titled, “How To Program Anything

Recommended prior reading:

This series talks about the C programming language, and everything you should know about it.  This series covers ANSI C with respect to C, the “C89” standard, the “C99” standard, and the “C11” additions to the language.  If you’re intimidated by pointers, no garbage collection, have a TI microcontroller and you’re using CodeComposer, or just want to gets your hands on a “middle-level” langauge, this series is for you.

  • The Nature of the C Programming Language – In this article we cover the C programming language: where did it come from, how it relates to other languages, what can it do, what doesn’t it do, and the future of the language.
  • Programming in C: Basic Data Types – In this article we cover the basic data types that variables can be, including charintfloat and double.  We talk about the sizes of each data type and their size modifiers.
  • Programming in C: Arrays and Strings – Here we cover the basics of arrays, which are sequences of a given data type, and its cousin (or really the same thing) the string, being an array of chars.
  • Programming in C: Pointers – Here we cover the idea of a variable that can hold the memory address of another variable or construct.  These are particularly powerful feature of the C language, but sometimes difficult to understand.
  • Programming in C: Arrays With Pointers – Arrays and pointers are quite related in C, offering two different ways to access the same kind of data: contiguous blocks in memory.  Here you can learn how to use pointer indexing with arrays.
  • Programming in C: Literals – When we program we need to be able toe specify some data straight in the code, by directly typing it.  This article deals with how we can write numbers, characters, and strings in the C language for use in our code.
  • Programming in C: Structures –  Rather than define a bunch of global arrays, we need to specify related data together.  This article covers aggregate data types, that is fields of data associated with each other through a structure.
  • Programming in C: Enumerations, Bit-Fields, and Unions – This extends the general idea of structures to include enumerations, bit-fields, and unions.  These are different ways of defining pieces of data that we can use elsewhere in our program.  Enumerations offer us int based constants, unions different ways of loooking at the same data, and bit-fields ways to access specific bits.
  • Programming in C: Typedef – Sometimes we don’t want to specify a complicated data structure over and over again, such as a pointer to a function.  We can use the typedef statement to short-hand our declarations and increase program portability and readability.
  • Programming In C: Arithmetic Operators – Now that we have basic and aggregate data types down, we need to make some expressions to do stuff with our data.  The arithmetic operators are just like they sound, they assign, divide, multiply, add and subtract our data.
  • Programming In C: Relational and Logical Operators – The relational operators compare values against each other to determine equality and difference, while the logical operators compare the “truthiness” of a given expression, chaining together simple operations into more complex ones.
  • Programming In C: Bitwise Operators – The bitwise operators perform operations on a bit level, that is, the ones and zeros that make up a value.  This is where C really shows it’s power as a flexible low-level language.
  • Programming in C: Program Operators and Order of Operations – These are operators that don’t neatly fall into other categories.  We also cover the order of operations for all operators, which is useful, but honestly it’s easier to make meaning clear with parentheses.

If you appreciate my tutorials please help support me through my Patreon.

If a monthly commitment is a bit much, consider buying me a cup of coffee instead.

photo credit: catsocmedia Of wires, buttons, screens and batteries via photopin (license)