Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > K&R Answers?

Reply
Thread Tools

K&R Answers?

 
 
Zach
Guest
Posts: n/a
 
      03-15-2008
I recall someone posting a website that had the complete K&R (2nd Ed.
- ANSI) answers posted but I cannot find the post.

Zach
 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      03-16-2008
Zach said:

> I recall someone posting a website that had the complete K&R (2nd Ed.
> - ANSI) answers posted but I cannot find the post.


Not complete (if I recall correctly) - but the Web site you're looking for
is:

<http://clc-wiki.net/wiki/K%26R2_solutions>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
 
 
 
Zach
Guest
Posts: n/a
 
      03-16-2008
On Mar 15, 8:09 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> Zach said:
>
> > I recall someone posting a website that had the complete K&R (2nd Ed.
> > - ANSI) answers posted but I cannot find the post.

>
> Not complete (if I recall correctly) - but the Web site you're looking for
> is:
>
> <http://clc-wiki.net/wiki/K%26R2_solutions>


Thanks Richard.

Zach
 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      03-16-2008
stop wrote:

>
> "Zach" <> wrote in message
>

news:3c8dd0c2-8f30-41ec-8b30-...
>> On Mar 15, 8:09 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
>>> Zach said:
>>>
>>> > I recall someone posting a website that had the complete K&R (2nd
>>> > Ed. - ANSI) answers posted but I cannot find the post.
>>>
>>> Not complete (if I recall correctly) - but the Web site you're
>>> looking for
>>> is:
>>>
>>> <http://clc-wiki.net/wiki/K%26R2_solutions>

>>
>> Thanks Richard.


> There's a worthwhile hard-copy available. _The C Solution Book_
> About 3/8" thick and fewer errata than the covers of Unleashed.


Do you mean /The C Answer Book/ by Clovis & Tondo?

> I'm curious what's at that link.


Solutions to some of the exercises in K&R2, contributed by various clc
participants.

 
Reply With Quote
 
stop
Guest
Posts: n/a
 
      03-16-2008

"Zach" <> wrote in message
news:3c8dd0c2-8f30-41ec-8b30-...
> On Mar 15, 8:09 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
>> Zach said:
>>
>> > I recall someone posting a website that had the complete K&R (2nd Ed.
>> > - ANSI) answers posted but I cannot find the post.

>>
>> Not complete (if I recall correctly) - but the Web site you're looking
>> for
>> is:
>>
>> <http://clc-wiki.net/wiki/K%26R2_solutions>

>
> Thanks Richard.
>
> Zach

There's a worthwhile hard-copy available. _The C Solution Book_ About 3/8"
thick and fewer errata than the covers of Unleashed.

I'm curious what's at that link.
--
"A man is accepted into church for what he believes--and turned out for
what he knows."

-Mark Twain


 
Reply With Quote
 
stop
Guest
Posts: n/a
 
      03-16-2008

"Richard Heathfield" <> wrote in message
news:v62dnT9flqzx-...
> Zach said:
>
>> I recall someone posting a website that had the complete K&R (2nd Ed.
>> - ANSI) answers posted but I cannot find the post.

>
> Not complete (if I recall correctly) - but the Web site you're looking for
> is:
>
> <http://clc-wiki.net/wiki/K%26R2_solutions>


I bookmarked the resource. It will save me occasionally from the abuse of
having to straighten out my C syntax here.

#from the site
The folks in comp.lang.c may tend to come across as Standard-thumping
fundamentalists, continuing to insist, with ramrod-straight demeanor, that
all code be strictly conforming, as if it's only important for its own sake.
But the insistence is not merely for its own sake: much more importantly,
it's for the sake of code that's correct, not just in the ANSI C Standard
sense, but in the much more important "works reliably in the real world"
sense. As Steve Summit wrote on an occasion when this issue came up, "I'm
not a Standard-thumping fundamentalist who worships at the altar of X3J11
because I'm an anal-retentive dweeb who loves pouncing on people who
innocently post code containing void main() to comp.lang.c; I'm a
Standard-thumping fundamentalist who worships at the altar of X3J11 because
it gives me eminently useful guarantees about the programs I write and helps
me ensure that they'll work correctly next week and next month and next
year, in environments I haven't heard of or can't imagine or that haven't
been invented yet, and without continual hands-on bugfixing and coddling by
me.
#end excerpt

Richard refers to the standard in the singular here. I think a lot of
questions get caught in the crosshairs between standards. What catches my
eye though is 3J as oppsoed to J3. Does X3J11 actually exist?

--
"A man is accepted into church for what he believes--and turned out for
what he knows."

-Mark Twain


 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      03-16-2008
stop said:

<snip>

> #from the site [ <http://clc-wiki.net/wiki ]
> The folks in comp.lang.c may tend to come across as Standard-thumping
> fundamentalists, continuing to insist, with ramrod-straight demeanor,
> that all code be strictly conforming, as if it's only important for its
> own sake. But the insistence is not merely for its own sake: much more
> importantly, it's for the sake of code that's correct, not just in the
> ANSI C Standard sense, but in the much more important "works reliably in
> the real world" sense. As Steve Summit wrote on an occasion when this
> issue came up, "I'm not a Standard-thumping fundamentalist who worships
> at the altar of X3J11 because I'm an anal-retentive dweeb who loves
> pouncing on people who innocently post code containing void main() to
> comp.lang.c; I'm a Standard-thumping fundamentalist who worships at the
> altar of X3J11 because it gives me eminently useful guarantees about the
> programs I write and helps me ensure that they'll work correctly next
> week and next month and next year, in environments I haven't heard of or
> can't imagine or that haven't been invented yet, and without continual
> hands-on bugfixing and coddling by me.
> #end excerpt
>
> Richard refers to the standard in the singular here.


I don't remember writing the above, and I'm reasonably sure I /didn't/
write the above. Any of it. The second half of it appears to have been
written by Steve Summit (presumably in a Usenet article). And the first
half? Well, I *might* have written it, but I don't think so.

> What catches my eye though is 3J as oppsoed to J3. Does X3J11
> actually exist?


It certainly did, because it was the ANSI Committee that produced the C89
Standard. Whether it still does, I have no idea.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      03-16-2008
Zach wrote:
> I recall someone posting a website that had the complete K&R (2nd Ed.
> - ANSI) answers posted but I cannot find the post.



Well about a K&R2 exercise posted in another thread. I think the answer:

http://clc-wiki.net/wiki/K%26R2_solu...r_2:Exercise_1

#include <stdio.h>
#include <limits.h>

int
main ()
{
printf("Size of Char %d\n", CHAR_BIT);
printf("Size of Char Max %d\n", CHAR_MAX);
printf("Size of Char Min %d\n", CHAR_MIN);
printf("Size of int min %d\n", INT_MIN);
printf("Size of int max %d\n", INT_MAX);
printf("Size of long min %ld\n", LONG_MIN); /* RB */
printf("Size of long max %ld\n", LONG_MAX); /* RB */
printf("Size of short min %d\n", SHRT_MIN);
printf("Size of short max %d\n", SHRT_MAX);
printf("Size of unsigned char %u\n", UCHAR_MAX); /* SF */
printf("Size of unsigned long %lu\n", ULONG_MAX); /* RB */
printf("Size of unsigned int %u\n", UINT_MAX); /* RB */
printf("Size of unsigned short %u\n", USHRT_MAX); /* SF */

return 0;
}


is wrong and a bit incomplete.


I think the correct one is:


#include <stdio.h>
#include <limits.h>

int main ()
{
printf("Size of Char %d\n", CHAR_BIT);
printf("Size of Char Max %d\n", CHAR_MAX);
printf("Size of Char Min %d\n", CHAR_MIN);
printf("Size of int min %d\n", INT_MIN);
printf("Size of int max %d\n", INT_MAX);
printf("Size of long min %ld\n", LONG_MIN); /* RB */
printf("Size of long max %ld\n", LONG_MAX); /* RB */
printf("Size of short min %d\n", SHRT_MIN);
printf("Size of short max %d\n", SHRT_MAX);
==> printf("Size of unsigned char max %u\n", (unsigned) UCHAR_MAX);
==> printf("Size of unsigned long max %lu\n", ULONG_MAX); /* RB */
==> printf("Size of unsigned int max %u\n", UINT_MAX); /* RB */
==> printf("Size of unsigned short max %u\n", USHRT_MAX); /* SF */

return 0;
}
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      03-16-2008
Ioannis Vranos wrote:
> Zach wrote:
>> I recall someone posting a website that had the complete K&R (2nd Ed.
>> - ANSI) answers posted but I cannot find the post.

>
>
> Well about a K&R2 exercise posted in another thread. I think the answer:
>
> http://clc-wiki.net/wiki/K%26R2_solu...r_2:Exercise_1
>
> #include <stdio.h>
> #include <limits.h>
>
> int
> main ()
> {
> printf("Size of Char %d\n", CHAR_BIT);
> printf("Size of Char Max %d\n", CHAR_MAX);
> printf("Size of Char Min %d\n", CHAR_MIN);
> printf("Size of int min %d\n", INT_MIN);
> printf("Size of int max %d\n", INT_MAX);
> printf("Size of long min %ld\n", LONG_MIN); /* RB */
> printf("Size of long max %ld\n", LONG_MAX); /* RB */
> printf("Size of short min %d\n", SHRT_MIN);
> printf("Size of short max %d\n", SHRT_MAX);
> printf("Size of unsigned char %u\n", UCHAR_MAX); /* SF */
> printf("Size of unsigned long %lu\n", ULONG_MAX); /* RB */
> printf("Size of unsigned int %u\n", UINT_MAX); /* RB */
> printf("Size of unsigned short %u\n", USHRT_MAX); /* SF */
>
> return 0;
> }
>
>
> is wrong and a bit incomplete.
>
>
> I think the correct one is:



More:


> #include <stdio.h>
> #include <limits.h>
>
> int main ()
> {

==> printf("Bits of Char %d\n", CHAR_BIT);
> printf("Size of Char Max %d\n", CHAR_MAX);
> printf("Size of Char Min %d\n", CHAR_MIN);
> printf("Size of int min %d\n", INT_MIN);
> printf("Size of int max %d\n", INT_MAX);
> printf("Size of long min %ld\n", LONG_MIN); /* RB */
> printf("Size of long max %ld\n", LONG_MAX); /* RB */
> printf("Size of short min %d\n", SHRT_MIN);
> printf("Size of short max %d\n", SHRT_MAX);
> ==> printf("Size of unsigned char max %u\n", (unsigned) UCHAR_MAX);
> ==> printf("Size of unsigned long max %lu\n", ULONG_MAX); /* RB */
> ==> printf("Size of unsigned int max %u\n", UINT_MAX); /* RB */
> ==> printf("Size of unsigned short max %u\n", USHRT_MAX); /* SF */
>
> return 0;
> }

 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      03-16-2008
Ioannis Vranos said:

<snip>
>
> Well about a K&R2 exercise posted in another thread. I think the answer:
>
> http://clc-wiki.net/wiki/K%26R2_solu...r_2:Exercise_1
>

<snip>
>
> is wrong and a bit incomplete.


Then why not submit your own version to the C wiki?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57