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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Surya Dutt](https://secure.gravatar.com/avatar/bc40b0c4cccead81b6220fab513613f5?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Surya Dutt
Courses Plus Student 2,875 Pointsreturn types
how did the function scope_it_out return a value called "gamma" even though the function 'scope_it_out' is declared as void?
2 Answers
William Li
Courses Plus Student 26,868 Pointsvoid scope_it_out() {
char bravo[] = "gamma";
printf("%s\n", bravo);
}
"gamma" was printed on the output console because the printf()
function is doing its job, but it's important to remember that printf()
and whatever results it generated are NOT the return value, in order for a function to have a return value, the return keyword must be used explicitly.
It's also worth knowing that, when calling a function with return value by itself, nothing will be outputted on the screen unless you pass its return value as argument to a printf()
function.
![Zack Richard](https://secure.gravatar.com/avatar/27593cc37f27d12c23afc0ad21976daf?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Zack Richard
6,313 PointsHi Surya,
Here is the scope_it_out function definition:
void scope_it_out() {
char bravo[] = "gamma";
printf( "%s\n", bravo );
}
Instead of returning a value, a call is made to printf, which prints the contents of the character array bravo. The scope_it_out function itself never returned a value. The call to printf is what caused the string gamma to be displayed.
![Surya Dutt](https://secure.gravatar.com/avatar/bc40b0c4cccead81b6220fab513613f5?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Surya Dutt
Courses Plus Student 2,875 PointsThanks Zack for clarifying my doubt.
Surya Dutt
Courses Plus Student 2,875 PointsSurya Dutt
Courses Plus Student 2,875 PointsThanks for the help William.It fixed my doubt.