Sample Video Frame
Exercise 5: Memorizing C Operators
When you learned your first programming language, it most likely involved going through a book, typing in code you didn't quite understand, and then trying to figure out how it worked. That's how I wrote most of my other books, and that works very well for beginners. In the beginning, there are complex topics you need to understand before you can grasp what all the symbols and words mean, so it's an easy way to learn.
However, once you already know one programming language, this method of fumbling around learning the syntax by osmosis isn't the most efficient way to learn a language. It works, but there is a much faster way to build both your skills in a language and your confidence in using it. This method of learning a programming language might seem like magic, but you'll have to trust me that it works surprisingly well.
How I want you to learn C is to first memorize all the basic symbols and syntax, then apply them through a series of exercises. This method is very similar to how you might learn human languages by memorizing words and grammar, and then applying what you memorize in conversations. With just a simple amount of memorization effort in the beginning, you can gain foundational knowledge and have an easier time reading and writing C code.
WARNING: Some people are dead against memorization. Usually, they claim it makes you uncreative and boring. I'm proof that memorizing things doesn't make you uncreative and boring. I paint, play and build guitars, sing, code, write books, and I memorize lots of things. This belief is entirely unfounded and detrimental to efficient learning. Please ignore anyone telling you this.
How to Memorize
The best way to memorize something is a fairly simple process:
Create a set of flashcards that have a symbol on one side and the description on the other. You could also use a program called Anki to do this on your computer. I prefer creating my own because it helps me memorize them as I make them.
Randomize the flashcards and start going through them on one side. Try your best to remember the other side of the card without looking.
If you can't recall the other side of the card, then look, repeat the answer to yourself, and then put that card into a separate pile.
Once you go through all the cards you'll have two piles: one pile of cards you recalled quickly, and another you failed to recall. Pick up the fail pile and drill yourself on only those cards.
At the very end of the session, which is usually 15-30 minutes, you'll have a set of cards you just can't recall. Take those cards with you wherever you go, when you have have free time, practice memorizing them.
There are many other tricks to memorizing things, but I've found that this is the best way to build instant recall on things you need to be able to use immediately. The symbols, keywords, and syntax of C are things you need instant recall on, so this method is the best for this task.
Also remember that you need to do both sides of the cards. You should be able to read the description and know what symbol matches it, as well as the description for a symbol.
Finally, you don't have to stop while you're memorizing these operators. The best approach is to combine this with exercises in this book so you can apply what you've memorized. See the next exercise for more on this.
The List of Operators
The first operators are the arithmetic operators, which are very similar to almost every other programming language. When you write the cards, the description side should say that it's an arithmetic operator, and what it does.
Relational operators test values for equality, and again they are very common in programming languages.
|Greater than equal
|Less than equal
Logical operators perform logic tests, and you should already know what these do. The only odd one is the logical ternary, which you'll learn later in the book.
Bitwise operators do something you likely won't experience often in modern code. They alter the bits that make up bytes and other data types in various ways. I won't cover this in my book, but they are very handy when working with certain types of lower level systems.
|Bitwise ones compliment
|Bitwise shift left
|Bitwise shift right
Assignment operators simply assign expressions to variables, but C combines a large number of other operators with assignment. So when I say
and-equal, I mean the bitwise operators, not the logical operators.
I'm calling these data operators but they really deal with aspects of pointers, member access, and various elements of data structures in C.
|Get the size of
|The address of
|The value of
Finally, there are a few miscellaneous symbols that are either frequently used for different roles (like
,), or don't fit into any of the previous categories for various reasons.
|Single-line comment start
|Multi-line comment start
|Multi-line comment end
Study your flashcards while you continue with the book. If you spent 15-30 minutes a day before studying, and another 15-30 minutes before bed, then you could most likely memorize all of these in a few weeks.
Register for Learn C the Hard Way
Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.