Thread: Parse Error in my first program - help!!

  1. #1
    Registered User
    Join Date
    Nov 2011

    Parse Error in my first program - help!!

    Hi Folks,

    Just starting out to learn Objective-C - this is my first program in Xcode and I have typed is just as it says in the book but I keep getting this error on the NSSLog line: parse error before '@' token


    #include <CoreFoundation/CoreFoundation.h>

    int main (int argc, const char * argv[]) {
    .. .. // insert code here...
    int firstnumber = 2;
    int secondnumber = 10;
    int total = 0;

    total = firstnumber + secondnumber;
    NSSLog (@"%d", total);

    .. .. return0;

    please help!!

    many thanks


  2. #2
    Registered User
    Join Date
    Sep 2006
    I'm not familiar with Objective C, what is the NSSLog (@ part do? The rest of the program looks ok, but you don't show a closing brace for the main() function.

    Welcome to the forum, Paul!

    Please use the advanced editor when you post code, and click on the # icon in the editors window to get a pair of code tags. Paste your code right between the code tags, and your code will be looking good (and keep any indentation, which is very important).
    Last edited by Adak; 11-05-2011 at 05:11 AM.

  3. #3
    Join Date
    Dec 2007
    Are you sure you don't mean NSLog, instead of NSSLog?

  4. #4
    Registered User
    Join Date
    Nov 2011

    Thanks Guys

    Thanks for the reply Adak - Sorry that ..should have read NSLog.

    As I am just starting out, all I know is that the Line is supposed to display the total to the console so you see it.

    I missed copying the closing brace to my post but it is there after the return statement.

    Many thanks for your welcome.


  5. #5
    Registered User
    Join Date
    Nov 2011

    Yep I did!

    yes my mistake - thanks for that.


  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    We don't have a dedicated Objective-C forum on this site.
    Thread moved.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. parse error on my program
    By makveli in forum C++ Programming
    Replies: 5
    Last Post: 11-12-2003, 12:17 PM
  2. parse error
    By sworc66 in forum C Programming
    Replies: 3
    Last Post: 08-31-2003, 09:16 PM
  3. parse error ???
    By teeyester in forum C++ Programming
    Replies: 2
    Last Post: 08-15-2003, 10:04 AM
  4. getting parse error
    By xenodvs1 in forum C Programming
    Replies: 1
    Last Post: 02-12-2003, 05:08 PM
  5. Parse Error
    By TheSki in forum C++ Programming
    Replies: 11
    Last Post: 09-15-2001, 12:45 AM