Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #108179

Re: main return value is helpfull?

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: main return value is helpfull?
Date 2017-04-16 21:11 +0100
Organization A noiseless patient Spider
Message-ID <87pogcnmd4.fsf@bsb.me.uk> (permalink)
References <7e8ec0c1-c5ac-4657-8c7f-5c26c5bf0c74@googlegroups.com>

Show all headers | View raw


esmaeel ensanimehr <eensanimehr@gmail.com> writes:

> i know some work can be don on inter parameter on main function.
> int main (int argc, char* argv[])
>
> argc, argv can be used in many points.
>
> but is there any useful example for main() return value?
>
> for example:
> int c = main();

That sort of use is very unusual.  The most common use of the return
value from main is by the operating system.  It is common for a program
to indicate that all went well by returning 0 or EXIT_SUCCESS and to
indicate a failure of some sort by returning EXIT_FAILURE.  Those
constants are defined in <stdlib.h>.  Some programs will even used the
return value to indicate exactly what kind of error occurred, but that
relies on knowledge of how the operating system uses the returned value.

Sticking to these conventions is useful when writing programs that are
tools to be used in what are called shell scripts.

-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

main return value is helpfull? esmaeel ensanimehr <eensanimehr@gmail.com> - 2017-04-16 12:51 -0700
  Re: main return value is helpfull? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-04-16 21:11 +0100
  Re: main return value is helpfull? supercat@casperkitty.com - 2017-04-16 13:19 -0700
    Re: main return value is helpfull? Keith Thompson <kst-u@mib.org> - 2017-04-16 14:41 -0700
      Re: main return value is helpfull? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2017-04-16 18:58 -0700
    Re: main return value is helpfull? Manfred <noname@invalid.add> - 2017-04-17 19:34 +0200
    Re: main return value is helpfull? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-04-17 13:57 -0400
      Re: main return value is helpfull? Keith Thompson <kst-u@mib.org> - 2017-04-17 12:19 -0700
        Re: main return value is helpfull? Manfred <noname@invalid.add> - 2017-04-18 13:03 +0200
          Re: main return value is helpfull? Keith Thompson <kst-u@mib.org> - 2017-04-18 09:29 -0700
  Re: main return value is helpfull? gordonb.xo0e7@burditt.org (Gordon Burditt) - 2017-04-17 04:40 -0500
  Re: main return value is helpfull? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-04-18 21:39 -0600

csiph-web