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


Groups > comp.lang.c > #45763

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

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: C Programming Language 2nd Ed, Exercise 1.9 and 1.12, Solution suggestion.
Date 2014-06-10 10:12 -0700
Organization None to speak of
Message-ID <lnwqcolmcl.fsf@nuthaus.mib.org> (permalink)
References (1 earlier) <C-20140609212332@ram.dialup.fu-berlin.de> <lnioo9n7gz.fsf@nuthaus.mib.org> <ln58jv$b7s$1@speranza.aioe.org> <lna99ln32t.fsf@nuthaus.mib.org> <bvnm1gF8p7fU1@mid.individual.net>

Show all headers | View raw


Cal Dershowitz <Cal@example.invalid> writes:
> On 6/9/2014 3:14 PM, Keith Thompson wrote:
[...]
>> This program:
>>
>>      int main() {
>>          main(42);
>>      }
>
> Wouldn't the new main interpret 42 as argv[0] in this instance?

As far as the C standard is concerned, the behavior is undefined.

Depending on the calling convention, main(42) *might* do something
equivalent to setting argc (probably not argv[0]) to 42, and probably
putting garbage into the argv pointer -- but since main's definition
doesn't declare argc, it can't refer to it anyway.  There is no
argc or argv in this case.

[...]

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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