473,614 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Solutions for the Kernighan and Ritchie

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,
Oct 2 '08 #1
13 7957
On Oct 2, 6:10 pm, another...@gmai l.com 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.o rg). In this way you could educate many
people.

Happy Hacking!
Oct 2 '08 #2
On Oct 2, 9:10*am, another...@gmai l.com 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.
Oct 2 '08 #3
user923005 said:
On Oct 2, 9:10 am, another...@gmai l.com 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.
It's true that I started the collection, but I have long since palmed it
off onto the clc wiki, which may be found at this URL:
http://clc-wiki.net/wiki/Main_Page

The K&R2 solutions page 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
Oct 2 '08 #4
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?
Oct 2 '08 #5
an********@gmai l.com 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 sm**@spam.cause way.com
If emailing me use my reply-to address
See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/
Oct 3 '08 #6
an********@gmai l.com 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.
Oct 3 '08 #7
On Oct 2, 9:10*am, another...@gmai l.com 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;
}
Oct 3 '08 #8
freeasinfreedom <fa*****@gmail. comwrote:
On Oct 2, 6:10 pm, another...@gmai l.com 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
Oct 3 '08 #9
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.
Oct 3 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
7908
by: Martin | last post by:
I am reading through Koenig and Moo's "Accelerated C++" and attempting the exercises. Are there any sample solutions somewhere? It's all very well me doing a solution, which seems to work, but for all I know it can be riddled with undefined behaviours and bad C++. The alternative is to post my solution to every single exercise and ask for guidance, but I actually think that is counter-productive and tantamount to spamming anyway. A set of...
90
3819
by: Jhon smith | last post by:
Hi all,Just wondering are there any problems with learning c from older books,as I have picked up some from 1988,1994,1997,1998. By using books of this age(Im on a tight budget)am I going to missout on anything in the langauge or has C remaind similar. I intend to use Dev-C++ on the windows platform. If any one feels theres anything I should be aware of,please help me out,I feel a bit lost with all thats out there regarding this language....
9
2420
by: niclane | last post by:
Hi, I was reading section 5.5 of Ritchie and Kernighan and saw the following: " ..... char amessage = "now is the time"; char *pmessage = "now is the time";
4
4368
by: Albert | last post by:
This isn't entirely related to C, but Kernighan and Ritchie asks in Execise 1-18 of their C programming language book to 'Write a program to remove trailing blanks and tabs from each line of input, and to delete entirely blank lines'. What do they mean by trailing?
8
2307
by: kaili | last post by:
i'm chinese i heard that "The C Programming Language " by Brian W. Kernighan, Dennis Ritchie is the best book for new learners. but it is unavailable here. i mearn there is nobody selled it. i wonder any body can help me???
21
6981
by: Spiros Bousbouras | last post by:
At http://www.lysator.liu.se/c/dmr-on-noalias.html Dennis Ritchie strongly denounces some noalias qualifier which was proposed for addition to the language at some point. Can someone give me some historical background and what it was supposed to do ? Was it like restricted pointers ?
2
2486
by: kalar | last post by:
I read from the kernighan and ritchie book about this function: /* qsort: sort v...v into increasing order */ void qsort(int v, int left, int right) { int i, last; void swap(int v, int i, int j); if (left >= right) /* do nothing if array contains */ return; /* fewer than two elements */ swap(v, left, (left + right)/2); /* move partition elem */ last = left; /* to v */
12
2969
by: coolcatjon | last post by:
Hey guys- I've decided to learn me some C, as any hacker must :) So I've got a C compiler handy, and I've downloaded the book by Kernergan and Richie that was recommended to me... One bad thing tho is it doesn't have solutions printed at the back, so what I'd like is to have a solutions manual to look at, instead of spending a lot of time thinking about each of the examples.
7
185
by: Ioannis Vranos | last post by:
In K&R2 errata page <http://www-db-out.research.bell-labs.com/cm/cs/cbook/2ediffs.html> there are some ambiguous errata, for which I propose solutions. Any comments are welcome. Ambiguous errata (mentioned first) of "The C Programming Language" 2nd Edition errata page (http://www-db-out.research.bell-labs.com/cm/cs/cbook/2ediffs.html), and
0
8197
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8142
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8589
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8287
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8443
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6093
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4136
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.