So if pointers are so great, why not only use pointers? For two reasons, both of which are consequences of the fact that pointers are a method of indirection. Indirection is, at heart, adding a step to the set of steps needed to get at the information you need. This makes the process of gettingRead more »

Because of C’s pass by value semantics, passing data into functions using parameters requires pushing and popping that data onto and off the stack, byte by byte. Using return values to pass data out of a function back to the callee also requires copying the data onto the stack. If you’re just passing or returningRead more »

So, as a result of some aberrant brain misfiring you’ve decided to start learning to code in C. You pretty quickly come across the idea of functions and your mind is blown. Then you try to write a function and all is not well. Not well at all. In fact things are looking a bitRead more »

Suppose you’re writing a function to double a given number. You might naively assume that this would be a reasonable solution: If you run it you’ll find number remains unchanged. This is, you might be surprised to discover, by design. It’s down to C’s pass by value semantics. Instead, use referential semantics as follows toRead more »