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 value main() 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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -