Hi. I'm new at programming. I bought an objective -c book and I just followed the book. I don't know why I get three errors. Help!
I got two nested functions error and one expected declaration error.
Help me, please!
Code:
#import <Foundation/Foundation.h>
// returns NO if the two intergers have the same
// value, YES otherwise
BOOL areIntsDifferent (int thing1, int thing2)
{
if (thing1 == thing2) {
return (NO);
} else {
return (YES);
} // areIntsDifferent
// given a YES value, return the human-readable
// string "YES". Otherwise return "NO"
NSString *boolString (BOOL yesNo)
{ *Nested functions are disabled, use -fnested-functions to re-enable*
if (yesNo == NO) {
return (@"NO");
} else {
return (@"YES");
}
} // boolString
int main (int argc, const char *argv[])
{ *Nested functions are disabled, use -fnested-functions to re-enable*
BOOL areTheyDifferent;
areTheyDifferent = areIntsDifferent (5, 5);
NSLog (@"are %d and %d different? %@",
5, 5, boolString(areTheyDifferent));
areTheyDifferent = areIntsDifferent (23, 42);
NSLog (@"are %d and %d different? %d",
23, 42, boolString(areTheyDifferent));
return(0);
} // main *Expected declaration or statement at end of input*
I got two nested functions error and one expected declaration error.
Help me, please!