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!

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) Fundamentals of C Anatomy of a C program

Return 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?


1 Answer

In 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:

Hi 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.