Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Objective-C Basics (Retired) Pointers and Memory Pointers

Understanding addresses and pointers [in C]

My understanding is that pointers are specific to saving memory?

They follow variables without having to hold the large amounts of data. I can later call the variable x by pointing to it rather than copying it.

How does that save memory?

Addresses are the places in memory in which the objects or variables are located.

Is this correct?

Thank you.

1 Answer

Martin Wildfeuer
Martin Wildfeuer
Courses Plus Student 11,071 Points

My understanding is that pointers are specific to saving memory?

Originally, yes. There's a bit more to it, though, have a look at Why C Pointers by Andrew Hardwick, that's a good read.

How does that save memory?

A pointer is a reference (the address) to data in memory. This data could be an instance of a person class, for example. This person object takes, let's say 50 kB of memory. By passing around this data via pointers, it will only ever take this 50 kB of memory. If it was copied, however, it would use another 50 kB of memory with every copy.

I hope this makes any sense, I always find myself in trouble when trying to find the right words for explaining pointers ;)