Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Solutions for the Kernighan and Ritchie

Reply
Thread Tools

Solutions for the Kernighan and Ritchie

 
 
anotherlin@gmail.com
Guest
Posts: n/a
 
      10-02-2008
Hi everyone,

I've read the Kernighan and Ritchie some time ago, and then again, but
this time I've done the full set of exercises. I figured it would be
nice to share them :

http://linkefong.free.fr/downloads/t...utions-1.0.zip

Your comments are welcome.

I've of course didn't peek in Tondo and Gimpel's book or Richard
Heathfield.

Regards,
 
Reply With Quote
 
 
 
 
freeasinfreedom
Guest
Posts: n/a
 
      10-02-2008
On Oct 2, 6:10 pm, (E-Mail Removed) wrote:
> Hi everyone,
>
> I've read the Kernighan and Ritchie some time ago, and then again, but
> this time I've done the full set of exercises. I figured it would be
> nice to share them :
>
> http://linkefong.free.fr/downloads/t...utions-1.0.zip
>
> Your comments are welcome.
>
> I've of course didn't peek in Tondo and Gimpel's book or Richard
> Heathfield.
>
> Regards,


Nice!

Since you like sharing your knowledge, you might be interested in
contributing to the free software community by adding you project to
savannah (savannah.gnu.org). In this way you could educate many
people.

Happy Hacking!
 
Reply With Quote
 
 
 
 
user923005
Guest
Posts: n/a
 
      10-02-2008
On Oct 2, 9:10*am, (E-Mail Removed) wrote:
> Hi everyone,
>
> I've read the Kernighan and Ritchie some time ago, and then again, but
> this time I've done the full set of exercises. I figured it would be
> nice to share them :
>
> http://linkefong.free.fr/downloads/t...utions-1.0.zip
>
> Your comments are welcome.
>
> I've of course didn't peek in Tondo and Gimpel's book or Richard
> Heathfield.


It might be nice to merge these solutions with Richard's collection
that is online.
 
Reply With Quote
 
anotherlin@gmail.com
Guest
Posts: n/a
 
      10-02-2008
I'll be glad to see them added to the clc-wiki. The admin has my
blessing to upload them.

I've basically answered all exercises, even those missing from
Richard's collection.

But first, is there somebody to check them for correctness? Any
comments?
 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      10-02-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote, On 02/10/08 23:09:
> I'll be glad to see them added to the clc-wiki. The admin has my
> blessing to upload them.


Thanks for getting his/her blessing first. Please include a link to the
original site when uploading them.

> I've basically answered all exercises, even those missing from
> Richard's collection.
>
> But first, is there somebody to check them for correctness? Any
> comments?


After uploading them they can be edited. So I would suggest upoading
them then posting links to them here asking for comment.
--
Flash Gordon
If spamming me sent it to (E-Mail Removed)
If emailing me use my reply-to address
See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/
 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      10-03-2008
(E-Mail Removed) writes:

> Hi everyone,
>
> I've read the Kernighan and Ritchie some time ago, and then again, but
> this time I've done the full set of exercises. I figured it would be
> nice to share them :
>
> http://linkefong.free.fr/downloads/t...utions-1.0.zip
>
> Your comments are welcome.


Looks good. That was a quick glance and if I have time I'll look
again. On one style issue, I was baffled by the large number of blank
lines. I won't make a fuss about style but it looked odd to me.

I spent a bit more time on one that I am currently familiar with (the
RPN calculator from chapter 4) and I am disappointed to see you also
have lost the original (correct in my opinion) K&R design of passing
getop the buffer size so you can prevent overflow. I'd count this as
a error.

--
Ben.
 
Reply With Quote
 
user923005
Guest
Posts: n/a
 
      10-03-2008
On Oct 2, 9:10*am, (E-Mail Removed) wrote:
> Hi everyone,
>
> I've read the Kernighan and Ritchie some time ago, and then again, but
> this time I've done the full set of exercises. I figured it would be
> nice to share them :
>
> http://linkefong.free.fr/downloads/t...utions-1.0.zip
>
> Your comments are welcome.
>
> I've of course didn't peek in Tondo and Gimpel's book or Richard
> Heathfield.


The test driver for exercise 4.2 does not test the atof() function:

int main ()

{
printf("%g\n", 123.45e-6);
return 0;
}

Probably, you meant to do this:

#include <stdio.h>
int main ()

{
printf("%g\n", atof("123.45e-6"));
return 0;
}
 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      10-03-2008
freeasinfreedom <(E-Mail Removed)> wrote:

> On Oct 2, 6:10 pm, (E-Mail Removed) wrote:
> > I've read the Kernighan and Ritchie some time ago, and then again, but
> > this time I've done the full set of exercises. I figured it would be
> > nice to share them :
> >
> > http://linkefong.free.fr/downloads/t...utions-1.0.zip


[ Edited for honesty ]

> Since you like sharing your knowledge, you might be interested in
> contributing to the free software community by adding you project to
> spammy (spamspam.spam.gnu.org).


Or rather, do not, since I cannot find an Earthly reason why anyone
would think answers to K&R exercises have anything to do with the
contents of that page.

Freedom? Freedom to advertise where it isn't wanted, apparently.

Richard
 
Reply With Quote
 
anotherlin@gmail.com
Guest
Posts: n/a
 
      10-03-2008
> Looks good. *That was a quick glance and if I have time I'll look
> again. *On one style issue, I was baffled by the large number of blank
> lines. *I won't make a fuss about style but it looked odd to me.


Well, I prefer things well separated. I use vi inside an 80x70
characters
xterm so there doesn't seem to be so much of them. I agree things can
look
differently and styles are a matter of personal taste.

> I spent a bit more time on one that I am currently familiar with (the
> RPN calculator from chapter 4) and I am disappointed to see you also
> have lost the original (correct in my opinion) K&R design of passing
> getop the buffer size so you can prevent overflow. *I'd count this as
> a error.


I started with the getop() function p78 of my 2nd edition book (41st
printing)
and there is no buffer size (prototype is int getop (char s[])). In
fact, none
of the exercises of this chapter specifically ask for checking buffer
overflow.
However, I agree that it would have been better a better answer.
 
Reply With Quote
 
anotherlin@gmail.com
Guest
Posts: n/a
 
      10-03-2008
> The test driver for exercise 4.2 does not test the atof() function:
[...]

Yes, you're right. I made a mistake and actually the atof() is not
correctly
tested and it has a bug! The exponent is not handled correctly, it
can be
fixed easily however. Thank you for pointing out this thing.
 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Questions about K&R (Kernighan and Ritchi) sandeep C Programming 57 04-29-2010 09:56 AM
searth for "C Programming Language" by Brian W. Kernighan, Dennis kaili C Programming 8 01-03-2007 05:13 AM
searth for "C Programming Language" by Brian W. Kernighan, Dennis kaili C Programming 1 01-01-2007 04:16 AM
What does Kernighan and Ritchie mean by 'trailing'? Albert C Programming 4 12-30-2005 03:13 PM
simple question regarding 5.5 of Ritchie & Kernighan niclane C Programming 9 06-20-2005 04:40 AM



Advertisments