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


Groups > comp.lang.c > #112260

Re: [poll/chitchat] What's the best main(){...} ?

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: [poll/chitchat] What's the best main(){...} ?
Date 2017-06-15 15:47 +0100
Organization A noiseless patient Spider
Message-ID <87y3st71ft.fsf@bsb.me.uk> (permalink)
References <035a57fe-e933-498a-a0a9-b7a4e4dc41f1@googlegroups.com> <oht8jb$oj4$1@news.albasani.net> <div0B.49$L47.11@fx41.iad>

Show all headers | View raw


scott@slp53.sl.home (Scott Lurndal) writes:

> Melzzzzz <Melzzzzz@zzzzz.com> writes:
>>On 2017-06-15, luser droog <luser.droog@gmail.com> wrote:
>>> The sine qua non of a C program is its entry point, main().
>>> Much discussion and argumentation have gone into the details
>>> of the declaration part. But I'm much more interested in the
>>> body. What's your favorite or ideal example of the perfect
>>> main() function?
>>>
>>> Here's mine. For a hypothetical program to do something or other.
>>>
>>> int main(){
>>>     return init()
>>>         && run();
>>> }
>>Well,
>>int main(int argc, char* argv[]) {
>>    return init(argc,argv) && run();
>>}
>
> Or if you want a non-boolean exit code from run
> to be used as the exit value:
>
> int
> main(int argc, const char * const *argv)
> {
>     return init(argc, argv), run();
> }

Or, since run my depends of things parsed from init and globals are a
Bad Idea:

  int main(int argc, char **argv)
  {
      return run(init(argc, argv));
  }

-- 
Ben.

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


Thread

[poll/chitchat] What's the best main(){...} ? luser droog <luser.droog@gmail.com> - 2017-06-14 22:30 -0700
  Re: [poll/chitchat] What's the best main(){...} ? Melzzzzz <Melzzzzz@zzzzz.com> - 2017-06-15 06:14 +0000
    Re: [poll/chitchat] What's the best main(){...} ? luser droog <luser.droog@gmail.com> - 2017-06-15 00:06 -0700
    Re: [poll/chitchat] What's the best main(){...} ? scott@slp53.sl.home (Scott Lurndal) - 2017-06-15 12:43 +0000
      Re: [poll/chitchat] What's the best main(){...} ? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-15 06:32 -0700
        Re: [poll/chitchat] What's the best main(){...} ? scott@slp53.sl.home (Scott Lurndal) - 2017-06-15 14:03 +0000
          Re: [poll/chitchat] What's the best main(){...} ? James Kuyper <jameskuyper@verizon.net> - 2017-06-15 10:07 -0400
      Re: [poll/chitchat] What's the best main(){...} ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-15 15:47 +0100
      Re: [poll/chitchat] What's the best main(){...} ? Tim Rentsch <txr@alumni.caltech.edu> - 2017-06-16 23:47 -0700
    Re: [poll/chitchat] What's the best main(){...} ? "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2017-06-16 18:32 +0800
  Re: [poll/chitchat] What's the best main(){...} ? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-15 06:31 -0700
  Re: [poll/chitchat] What's the best main(){...} ? David Brown <david.brown@hesbynett.no> - 2017-06-15 16:18 +0200
    Re: [poll/chitchat] What's the best main(){...} ? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-15 07:35 -0700
      Re: [poll/chitchat] What's the best main(){...} ? David Brown <david.brown@hesbynett.no> - 2017-06-15 17:35 +0200
        Re: [poll/chitchat] What's the best main(){...} ? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-15 08:41 -0700
          Re: [poll/chitchat] What's the best main(){...} ? David Brown <david.brown@hesbynett.no> - 2017-06-15 21:18 +0200
            Re: [poll/chitchat] What's the best main(){...} ? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-15 12:39 -0700
            Re: [poll/chitchat] What's the best main(){...} ? David Kleinecke <dkleinecke@gmail.com> - 2017-06-15 19:58 -0700
        Re: [poll/chitchat] What's the best main(){...} ? Richard Heathfield <rjh@cpax.org.uk> - 2017-06-15 17:01 +0100
          Re: [poll/chitchat] What's the best main(){...} ? Melzzzzz <Melzzzzz@zzzzz.com> - 2017-06-15 16:13 +0000
            Re: [poll/chitchat] What's the best main(){...} ? Richard Heathfield <rjh@cpax.org.uk> - 2017-06-15 17:42 +0100
              Re: [poll/chitchat] What's the best main(){...} ? David Brown <david.brown@hesbynett.no> - 2017-06-15 21:21 +0200
                Re: [poll/chitchat] What's the best main(){...} ? Gareth Owen <gwowen@gmail.com> - 2017-06-15 20:48 +0100
                Re: [poll/chitchat] What's the best main(){...} ? Richard Heathfield <rjh@cpax.org.uk> - 2017-06-15 20:55 +0100

csiph-web