What\'s the difference? Which is preferred, or when should I use each one respectively?
There are conventions for what sorts of status values certain programs should return. The most common convention is simply 0 for success and 1 for failure. Programs that perform comparison use a different convention: they use status 1 to indicate a mismatch, and status 2 to indicate an inability to compare. Your program should follow an existing convention if an existing convention makes sense for it.
Some non-POSIX systems use different conventions for exit status values.
For greater portability, you can use the macrosEXIT_SUCCESSandEXIT_FAILUREfor the conventional status value for success and failure, respectively. They are declared in the file stdlib.h.