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


Groups > comp.lang.c > #45713

Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion.

From glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups comp.lang.c
Subject Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion.
Date 2014-06-09 21:23 +0000
Organization Aioe.org NNTP Server
Message-ID <ln58jv$b7s$1@speranza.aioe.org> (permalink)
References <7128848c-179a-44d1-b2a8-cf8163bf6d2c@googlegroups.com> <C-20140609212332@ram.dialup.fu-berlin.de> <lnioo9n7gz.fsf@nuthaus.mib.org>

Show all headers | View raw


Keith Thompson <kst-u@mib.org> wrote:

(snip)

> I just checked, and K&R2 actually uses the old "main()" form in its
> examples.  I'd call that a minor flaw in an otherwise very good book,
> and I wouldn't reject K&R2 for that reason.
 
> The empty parentheses are also obsolescent, and have been since the 1989
> ANSI C standard.  The preferred way to define the main function is:
 
>    int main(void) { /* ... */ }
 
> I've never seen a compiler that would complain about "int main()", but
> "int main(void)" is more explicit (and, I've argued, more clearly valid).
 

Writing in both C and Java, I might be a little more sensitive to
the differences between them.

Since C's main is supposed to have arguments (usually argc and argv)
but it is usual not to put them in if I am not using them, I prefer
the () form, with the (void) form when there are never any arguments.

That is unlike Java, where the argument signatures (I think that
is what they call them) must match. 

To allow for varargs, most calling conventions used with C allow
for fewer arguments. As well as I know it, strictly that is only
allowed for actual varargs functions. Different calling conventions
could be used for varargs and non-varargs, but usually aren't.

I haven't looked yet how Java does System.out.format(),
though I use it more and more in my Java programs.

-- glen

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


Thread

C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Christos Kokaliaris <chrisk.msor@gmail.com> - 2014-06-09 12:12 -0700
  Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Christos Kokaliaris <chrisk.msor@gmail.com> - 2014-06-09 12:41 -0700
    Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Barry Schwarz <schwarzb@dqel.com> - 2014-06-09 13:16 -0700
    Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-12 09:08 -0700
      Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. raltbos@xs4all.nl (Richard Bos) - 2014-06-12 16:35 +0000
        Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-13 07:27 -0700
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Jorgen Grahn <grahn+nntp@snipabacken.se> - 2014-06-14 00:13 +0000
            Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-16 07:07 -0700
              Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Jorgen Grahn <grahn+nntp@snipabacken.se> - 2014-06-16 20:04 +0000
                Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-17 08:56 -0700
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. raltbos@xs4all.nl (Richard Bos) - 2014-06-16 12:53 +0000
            Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-16 08:00 -0700
              Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Kaz Kylheku <kaz@kylheku.com> - 2014-06-16 16:01 +0000
                Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-17 08:24 -0700
              Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. raltbos@xs4all.nl (Richard Bos) - 2014-06-18 10:50 +0000
                Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-26 19:07 -0700
  Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Kaz Kylheku <kaz@kylheku.com> - 2014-06-09 19:51 +0000
  Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Jorgen Grahn <grahn+nntp@snipabacken.se> - 2014-06-09 20:15 +0000
  Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Christos Kokaliaris <chrisk.msor@gmail.com> - 2014-06-09 13:21 -0700
  Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Keith Thompson <kst-u@mib.org> - 2014-06-09 13:39 -0700
    Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-06-09 21:23 +0000
      Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Kaz Kylheku <kaz@kylheku.com> - 2014-06-09 21:43 +0000
        Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-06-10 00:17 +0000
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. "BartC" <bc@freeuk.com> - 2014-06-10 11:13 +0100
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Keith Thompson <kst-u@mib.org> - 2014-06-10 07:38 -0700
        Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. raltbos@xs4all.nl (Richard Bos) - 2014-06-10 10:23 +0000
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Dr Nick <nospam-4@temporary-address.org.uk> - 2014-06-10 18:55 +0100
      Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Keith Thompson <kst-u@mib.org> - 2014-06-09 15:14 -0700
        Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-06-10 00:21 +0000
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. James Kuyper <jameskuyper@verizon.net> - 2014-06-09 21:37 -0400
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Keith Thompson <kst-u@mib.org> - 2014-06-10 07:45 -0700
            Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-11 01:32 -0700
        Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Cal Dershowitz <Cal@example.invalid> - 2014-06-09 23:14 -0700
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. raltbos@xs4all.nl (Richard Bos) - 2014-06-10 10:14 +0000
            Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2014-06-10 22:06 +0300
              Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. raltbos@xs4all.nl (Richard Bos) - 2014-06-11 16:16 +0000
                Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Kaz Kylheku <kaz@kylheku.com> - 2014-06-11 16:47 +0000
                Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2014-06-11 20:50 +0300
            Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. raltbos@xs4all.nl (Richard Bos) - 2014-06-11 16:16 +0000
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2014-06-10 08:23 -0600
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Keith Thompson <kst-u@mib.org> - 2014-06-10 10:12 -0700
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-12 08:39 -0700
            Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Robert Wessel <robertwessel2@yahoo.com> - 2014-06-12 12:30 -0500
        Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Seungbeom Kim <musiphil@bawi.org> - 2014-06-10 23:34 -0700
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-11 00:35 -0700
          Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Keith Thompson <kst-u@mib.org> - 2014-06-11 08:35 -0700
            Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion. Kaz Kylheku <kaz@kylheku.com> - 2014-06-11 15:49 +0000

csiph-web