Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 25, 2006, 03:36 PM   #1
macsrockmysocks
macrumors regular
 
Join Date: Feb 2006
Help with basic Obj-c code?

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?
__________________
I support Dr. Anna Pou. I personally know her, and she is a great person. Support her!
macsrockmysocks is offline   0 Reply With Quote
Old Jul 25, 2006, 03:49 PM   #2
exabytes18
macrumors 6502
 
Join Date: Jun 2006
Location: Suburb of Chicago
Send a message via AIM to exabytes18
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;"
exabytes18 is offline   0 Reply With Quote
Old Jul 25, 2006, 04:09 PM   #3
macsrockmysocks
Thread Starter
macrumors regular
 
Join Date: Feb 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.
__________________
I support Dr. Anna Pou. I personally know her, and she is a great person. Support her!
macsrockmysocks is offline   0 Reply With Quote
Old Jul 25, 2006, 04:10 PM   #4
mduser63
macrumors 68040
 
mduser63's Avatar
 
Join Date: Nov 2004
Location: Salt Lake City, UT
Send a message via AIM to mduser63
Quote:
Originally Posted by exabytes18
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;"

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.
mduser63 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Learning Obj-c feedback arkmannj iPhone/iPad Programming 11 Apr 24, 2014 11:22 PM
Free note app with basic formatting basic HTML Subu iPhone and iPod touch Apps 0 Mar 1, 2013 03:44 AM
C, Obj-C, C++, some questions argh silentownage001 Mac Programming 24 Feb 12, 2013 01:20 AM
What to learn aside Obj C Will0827 iPhone/iPad Programming 8 Sep 27, 2012 03:07 PM
Need help with indexing (Java or Obj-C) iVikD Mac Programming 5 Jul 5, 2012 05:43 PM

Forum Jump

All times are GMT -5. The time now is 07:01 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC