Why can’t the main() function have a return type of double or String?

Because the operating systems program loader only accepts an int as a return value.
This allows sshell scripts some form of control — continue onto the next program if the previous one returned a zero. if it were a float, this would break a consierable number of existing scripts that do exact comparisions. If a string, then not only would the format values of the strings themselves have to be coordinated (not all strings are zero terminated) but likewise the encoding of the string (UTF16BE, Ascii, etc) and and the actual values.
Basically the only convention used is negative for an  error , a zero for success, and maybe positive value for a warning. .  Anything more complicated and a LOT of things break or become impossible to maintain.

Answer by Lance Diduck:

Because the operating systems program loader only accepts an int as a return value.
This allows sshell scripts some form of control — continue onto the next program if the previous one returned a zero. if it were a float, this would break a consierable number of existing scripts that do exact comparisions. If a string, then not only would the format values of the strings themselves have to be coordinated (not all strings are zero terminated) but likewise the encoding of the string (UTF16BE, Ascii, etc) and and the actual values.
Basically the only convention used is negative for an  error , a zero for success, and maybe positive value for a warning. .  Anything more complicated and a LOT of things break or become impossible to maintain.

Why can't the main() function have a return type of double or String?

Advertisements

Leave a comment

Filed under Life

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s