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 trialJake Nisenboim
3,374 PointsReturn 0 in C
As I understand,
return 0;
indicates that the program ran properly.
Why would a programmer have
return 1;
in their code, indicating that it did not run properly? I am not understanding correctly?
Should I always use return 0, or is that incorrect?
Thanks!
1 Answer
mkmk
15,897 PointsIn C the main function has to return an integer. A zero has been established as the code for success, but other numbers have been used as exit codes to return a variety of messages.
Here's an example list of Window's exit codes:
http://www.hiteksoftware.com/knowledge/articles/049.htm
Jake Nisenboim
3,374 PointsJake Nisenboim
3,374 PointsHi mkmk,
I believe I understand what you are saying however I do not understand what changing that number within the code would mean for the outcome of the actual program.
Thanks.