Like Tree1Likes
  • 1 Post By rags_to_riches

Parse Error in my first program - help!!

This is a discussion on Parse Error in my first program - help!! within the Tech Board forums, part of the Community Boards category; Hi Folks, Just starting out to learn Objective-C - this is my first program in Xcode and I have typed ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    3

    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

    code...

    #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

    Paul



  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,641
    Are you sure you don't mean NSLog, instead of NSSLog?
    dennis.cpp likes this.

  4. #4
    Registered User
    Join Date
    Nov 2011
    Posts
    3

    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.

    Paul

  5. #5
    Registered User
    Join Date
    Nov 2011
    Posts
    3

    Yep I did!

    yes my mistake - thanks for that.

    Paul

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,341
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 11:17 AM
  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, 04:08 PM
  5. Parse Error
    By TheSki in forum C++ Programming
    Replies: 11
    Last Post: 09-15-2001, 12:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21