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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Help with port forwarding for Security software? PPFee Mac Applications and Mac App Store 1 Dec 11, 2011 03:34 PM
Help with c code for files coopf iPhone/iPad Programming 2 Nov 19, 2010 09:21 PM
Got First Camera, Need help with Basics Sweener88 Digital Photography 5 Oct 13, 2006 08:42 PM
Need help with basics DaveP924 Mac Basics and Help 3 Jun 8, 2006 06:58 PM
Help with basic document backup Stretch Mac Basics and Help 12 Sep 7, 2005 05:36 PM


All times are GMT -5. The time now is 11:56 AM.

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

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