Help with basic Obj-c code?

Discussion in 'Mac Programming' started by macsrockmysocks, Jul 25, 2006.

  1. macrumors regular

    Feb 21, 2006
    I have received my new book on ObjC today and am doing an exercise. Here is the code that I am having errors from:
    #import <stdio.h>
    int main(int argc, char *argv[])
    int sum;
    // Compute Result
    sum = 25 + 37 - 19
    // Display Results
    printf ("The answer is %i\n", sum);
    return 0;
    It says there is a problem with my printf line, but I don't see it. Do any of you?
  2. macrumors 6502

    Jun 14, 2006
    Suburb of Chicago
    I don't program in obj-c, and don't know if this is a typo, but try adding a semicolon to make "sum = 25 + 37 - 19;"
  3. thread starter macrumors regular

    Feb 21, 2006
    I cannot believe I missed that. I am so stupid! Oh well, you learn from mistakes. Now, I am off to Chapter 3- Objects.
  4. macrumors 68040


    Nov 9, 2004
    Salt Lake City, UT

    That is most likely the problem. One thing you should learn is that often when the compiler complains about a particular line, it is often the line above it that's the real problem.

Share This Page