Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Please explain structs for me!

I don't really get the concept of structs. What's the point of having them? We made a whole bunch of variables, but didn't really do anything.

1 Answer

Hi Tristan,

A struct basically is a way to tie a set of related data together. for instance if I wanted a person struct I could have a char for name, an int for age and a char for job. I like to compare to compare them to classes in objective-c because they hold certain properties (or primitives because C is not object oriented) and these properties normally relevant to each other. a real world example is x and y coordinates are part of a struct, both x and y are relevant to each other so we decide to put them together in a struct.

for more info it's definitely worth googling,

Happy hacking, Kai.

Thanks Kai

No problem :)