Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: what is the output |
| Date | 2011-07-04 14:22 -0700 |
| Organization | None to speak of |
| Message-ID | <ln7h7x4u81.fsf@nuthaus.mib.org> (permalink) |
| References | <fde0c807-8924-4328-887b-42495fcc80c5@d26g2000prn.googlegroups.com> <iuqa1r$soe$1@dont-email.me> <bfa37ea9-d7cd-457b-8f28-070a945a8da6@p10g2000prf.googlegroups.com> <lnwrfz3vmc.fsf@nuthaus.mib.org> <6b2f8cbb-e8fc-45a2-b0dd-303418bc0234@r27g2000prr.googlegroups.com> |
Chad <cdalten@gmail.com> writes:
> On Jul 3, 2:24 pm, Keith Thompson <ks...@mib.org> wrote:
>> Chad <cdal...@gmail.com> writes:
>> > On Jul 3, 10:47 am, Eric Sosman <esos...@ieee-dot-org.invalid> wrote:
>> >> On 7/3/2011 12:32 PM, vinay kumar wrote:
>>
>> >> > main()
>> >> > {
>> >> > int d=010;
>> >> > printf("%d",d);
>> >> > }
>>
>> >> > please give with explanation
>>
>> >> Undefined, because a variable-argument function is used
>> >> without a prototyped declaration.
>>
>> >> Also implementation-defined, because the final line of text
>> >> output is not terminated with a newline.
>>
>> >> Also either (1) "semi-undefined" because a C90 int-valued
>> >> function returns without returning a value, or (2) implementation-
>> >> defined because a C99 compiler must diagnose a function definition
>> >> without return type, and *if* it translates the program anyhow it
>> >> gives it an implementation-defined meaning.
>>
>> >> ... but the answer you're probably looking for is "8", and
>> >> the explanation will be found in the low-numbered pages of your
>> >> C textbook -- you know, that unopened volume you've been carrying
>> >> around. Open it (it won't bite you), and see what it has to say
>> >> about "integer constants" or some similar term.
>>
>> > I know I shouldn't do this, but I'm going to take the bait on this
>> > one. How do you figure the output is the "8".
>>
>> Did you try running the program? What output did you get?
>>
>> Eric already explained how to find the explanation: see what your C
>> textbook (or on-line tutorial, or copy of the standard) says about
>> integer constants.
>
> I got the number "8" after I compiled and ran this code on my Linux
> box here at home. I just wasn't clear on why the computer produced the
> number "8" and not the number "10".
That's probably because you ignored the advice several people have
given, to consult your C reference and see what it has to say about
integer constants.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"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 | Next — Previous in thread | Next in thread | Find similar | Unroll thread
what is the output vinay kumar <vinay5b9@gmail.com> - 2011-07-03 09:32 -0700
Re: what is the output "Joachim Schmitz" <nospam.jojo@schmitz-digital.de> - 2011-07-03 19:43 +0200
Re: what is the output Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-03 13:47 -0400
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-03 12:15 -0700
Re: what is the output Chad <cdalten@gmail.com> - 2011-07-03 13:55 -0700
Re: what is the output "osmium" <r124c4u102@comcast.net> - 2011-07-03 16:20 -0500
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-03 14:24 -0700
Re: what is the output Chad <cdalten@gmail.com> - 2011-07-03 16:13 -0700
Re: what is the output "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-07-03 21:10 -0400
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-04 14:22 -0700
Re: what is the output Todd Carnes <toddcarnes@gmail.com> - 2011-07-05 03:30 +0000
Re: what is the output John Gordon <gordon@panix.com> - 2011-07-05 02:26 +0000
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-03 18:30 -0700
Re: what is the output Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-03 21:58 -0400
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-04 17:10 -0700
Re: what is the output Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-04 21:42 -0400
Re: what is the output Shao Miller <sha0.miller@gmail.com> - 2011-07-04 22:51 -0400
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-06 16:23 -0700
Re: what is the output Michael Press <rubrum@pacbell.net> - 2011-07-03 21:23 -0700
Re: what is the output Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-07-03 14:06 -0600
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-03 18:19 -0700
Re: what is the output Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-03 22:12 -0400
Re: what is the output Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-07-03 21:16 -0600
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-04 13:59 -0700
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-04 17:15 -0700
Re: what is the output Martin Ambuhl <mambuhl@earthlink.net> - 2011-07-04 17:21 -0400
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-04 17:27 -0700
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-04 18:07 -0700
Re: what is the output Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-06 17:08 -0700
Re: what is the output "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-07-04 22:19 -0400
Re: what is the output Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-04 23:19 -0400
Re: what is the output Keith Thompson <kst-u@mib.org> - 2011-07-05 08:34 -0700
Re: what is the output Shao Miller <sha0.miller@gmail.com> - 2011-07-04 18:26 -0400
Re: what is the output Todd Carnes <toddcarnes@gmail.com> - 2011-07-05 03:36 +0000
csiph-web