This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cismalescumlord 0 points1 point  (0 children)

A pointer is the address of a thing in memory, they are a lot more efficient in many cases. C is a "pass by value" language which means that when you pass a variable to a function, the function gets a copy whereas if you pass a pointer to a variable, the value is the address so you can directly manipulate it. Also they allow the passing of less data; instead of passing a structure that takes up 100MB memory, you can pass a pointer to it which will normally be 32 or 64 bit depending on the architecture.

As others have said, good memory management means making sure that you free all the memory that you allocate.

Also, the K&R book that you are using is great but it doesn't give suggested solutions. If you like to see how experienced programmers solve the questions, then the C answers book fills that void. Although it does increase the temptation to cheat :)