c - Is returning zero from main necessary, and how can the return value from main be useful? -
c - Is returning zero from main necessary, and how can the return value from main be useful? -
i know it's been convention in c89 homecoming 0 integer value main in c program, this:
int main() { /* useful here */ homecoming 0; }
this homecoming "successful" result operating system. still consider myself novice (or intermediate programmer @ best) in c, date i've never understood why important.
my guess is, useful homecoming result if you're tying output of programme input of another, i'm not sure. i've never found useful, or maybe don't understand intention is.
my questions:
is returning 0 necessary c program? how homecoming valuemain()
useful?
when writing scripts (like in bash, or cmd.exe on windows) can chain commands && , || operators.
canonically, a && b
run b
if result of a
zero, , a || b
run b
if a
returned nonzero.
this useful if wish conditionally run command if previous 1 succeeded. example, delete file if contains word foo. utilize :
grep foo myfile && rm myfile
grep
returns 0 when there match, else nonzero.
c return-value exit-code
Comments
Post a Comment