开发者

Nested functions are disabled; use f-nested functions to re-enable

I am just learning Objective C and I am having great difficulty. This is what is typed and it开发者_运维知识库 is giving me an error. I typed the text that is bold. What is wrong with it. It gives me the nested function error right after int main(void)

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [NSAutoreleasePool alloc] init];

// **#include <stdio.h>
int main(void)
int amount = 1000000;
printf("The amount in your account is $%i\n", amount);
return 0;
}**
NSLog(@"Hello, World!");
[pool drain];
return 0;
}


Your problem is that C and it's brethren do not like functions within functions (putting aside gcc extensions for now).

What you seem to be trying to do is to declare a whole new main inside your main. That's a big no-no. What I suspect is that you've cut-and-pasted an entire C program into the middle of your existing main.

Start with:

#import <Foundation/Foundation.h>
#include <stdio.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [NSAutoreleasePool alloc] init];
    int amount = 1000000;
    printf("The amount in your account is $%i\n", amount);
    NSLog(@"Hello, World!");
    [pool drain];
    return 0;
}

and work your way up from there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜