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

Chris K
Chris K
7,425 Points

Why are some things declared before int main() and some things after the return?

I'm about 2 minutes into the video on Structs and still can't figure out (or must have missed) the location of where we declare variables/work with data. Why do certain parts of a program go before or after the int main()? Why wouldn't everything go in order after the main?

Thanks!

3 Answers

obey me
obey me
1,135 Points

I could tell you that "it is a must " for every [class ,struct, void function,and others] to be declared and implemented outside of the int main () then you could only call them inside of your main to perform action on .I hope this help

Chris K
Chris K
7,425 Points

Thanks! Is there a particular order that those [class, struct, void function, etc] must be in (before/after) the int main() ?

obey me
obey me
1,135 Points

There is no order ,just make sure you declare them then call to call them in the main .

Chema Castellanos
Chema Castellanos
3,984 Points

I think that for the purposes of organization he first declares things and the codes the functions that actually do things like the makeSphere function

ruo pu koh
ruo pu koh
2,669 Points

Why is the implementing of makeSphere not inside Main(), but after it.