Help with basic Obj-c code?

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

  1. macrumors regular

    #1
    I have received my new book on ObjC today and am doing an exercise. Here is the code that I am having errors from:
    Code:
    #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

    #2
    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. macrumors regular

    #3
    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

    mduser63

    #4

    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