If you really want to kick butt with C, you need to understand how C handles memory.
The C language gives you a lot more control over how your program uses the computer’s memory. In this chapter, you’ll strip back the covers and see exactly what happens when you read and write variables. You’ll learn how arrays work, how to avoid some nasty memory SNAFUs, and most of all, you’ll see how mastering pointers and memory addressing is key to becoming a kick-ass C programmer.
Pointers are one of the most fundamental things to understand in the C programming language. So what’s a pointer? A pointer is just the address of a piece of data in memory.
Pointers are used in C for a couple of reasons.
To best understand pointers, go slowly.
Instead of passing around a whole copy of the data, you can just pass a pointer.
You might want two pieces of code to work on the same piece of data rather than a separate copy.
Pointers help you do both these things: avoid copies and share data. But if pointers are just addresses, why do some people find them confusing? Because they’re a form of indirection. If you’re not careful, you can ...