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

Ryan Jin
Ryan Jin
15,337 Points

Why it is *c

Why it is *c for an array. I thought float *c is a pointer that points to a float variable

Stepan Ulyanin
Stepan Ulyanin
11,318 Points

Because in C along with C++ and some other languages the array name is a pointer to the memory address of the first element of the array;

int my_array[3] = {1, 2, 3}; // creates an array

printf("%04x", array); //will print the memory address of my_array[0] which is 1

that's why they pass the pointer to a float which is the first element of the array, coming from there you can just use the subscript operator to de-reference it (c[0] or c[1]) - [ ] is the subscript operator and it will display the value that is stored at the memory address connected to the array through the pointer;

I hope it helps!