very basic C question -- K & R on a Mac

  • Thread starter Ben Jacobs-Swearingen
  • Start date
B

Ben Jacobs-Swearingen

Hello,

I just started learning C a couple weeks ago from Kernighan and
Ritchie (first edition -- I can't afford the newer second edition), and
have really enjoyed it so far. But I am having trouble making the code
at the end of Chapter 5 -- the sort function that uses function pointers
-- to work on my machine (233 Mhz iMac, 160 MB RAM, OS 9.2 ; MPW
environment). When I try to compile sort.c with the Symantec C compiler
it gives me all sorts of strange errors about how the syntax (copied
straight from the book!) is screwed up. Now when I'm at school and
working on an OSX machine running gcc, sort.c will compile correctly
along with everything else, but the input is all wrong (the pointers
aren't working properly). I *think* I've traced the problem in the
gcc-compile to sort.c as well, but I'm not sure. I really don't like
being stalled with this because I want to continue doing the exercises
(which are really fun) that are based on this code.

Having looked at the code many times by now and made sure I copied
the base code from the book correctly, I'm at my wits end. Does anyone
know any reason why the Kernighan & Ritchie code from the end of Chapter
5 (1st edition) might not compile correctly on a Mac? I suspect it has
to do with some obscure detail involving the inner workings of the
computer (that would necessitate a different arrangement of pointers?),
or (less likely) some incompatibility with ANSI C, but I'm not sure. I'd
much appreciate any constructive advice anyone could give me... thanks.
I can provide my source files for someone to look at if you would think
it would help.

Ben
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top