Macintosh and C question

topic posted Tue, December 13, 2005 - 3:17 PM by  Unsubscribed
Share/Save/Bookmark
Advertisement
So, I'm in the process of learning C. I have about a year and a half of programming experience in Matlab.

I'm working through Brian Kernighan's "The C Programming Language" and I keep running into problems with my programs hanging. They compile just fine but I don't get any output. It's as if they're caught in a loop they can't get out of. I've double checked my code and it looks just fine (coming from the book).

Anyone have any ideas? I'm working on a Mac G4 and compiling using gcc in unix. Love to hear any ideas.
posted by:
Unsubscribed
Advertisement
Advertisement
  • Re: Macintosh and C question

    Tue, December 13, 2005 - 5:37 PM
    I would put in some print to screen statements such as "spot 1", "spot 2", "Got this far 1", "Got this far 2", etc. in various places in your code, in each loop for sure, and then run the code. Then you can see how far into your code the program is running, or if it gets stuck in a loop, you will see the same "spot 5" or what ever a million times on your screen.

    Its worth trying...
    • Unsu...
       

      Re: Macintosh and C question

      Tue, December 13, 2005 - 6:29 PM
      Excellent suggestion, Seth. Thank you! Since I've been working Matlab, I've had very little need for the debugger so I'm pretty unfamiliar. The C programs I'll be writing and working with will be run in the Unix environment. Do you guys think it would be best to use a debugger such as GNU's GDB or should i try something else?
      • Re: Macintosh and C question

        Tue, December 13, 2005 - 6:57 PM

        Alan,

        GDB will help a lot, once you get used to how to run it. Apple's version has hooks that let XCode do the graphical debug thing, but that's Apple's own, and if you're ever on another *nix without XCode, knowing some basics on GDB will help. If you post or send some of your C code, I can help you debug it if you wish.

        Regards,

        John

        Falling You - exploring the beauty of voice and sound
        www.fallingyou.com