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 trialChristopher Ponce De Leon
220 PointsExplanation of void
In the video Douglass Turner said that when your function has a return type of void it means that the function would not return anything;
But when he calls the function in main() it returns something?
2 Answers
Seab Jackson
5,692 PointsActually he's right. When the function has a return type of void it doesn't return anything. The function main() though has a return type, and that's why we declare it as: int main(). Main is expecting a return value that is an integer. It turns out that return 0 is reserved for implying that our program was executed successfully, and that no errors occurred in the program. Thus, this return value was for the main function, and not for the scope_it() function.
Vrezh Gulyan
11,161 PointsThe answer to your question is that the function truly returns nothing. That is why its return type is void. The printing happens inside of the void function. When we call it from main , print gets executed inside of scope_it_out and prints to the console.