嵌套函数被禁用;使用 f 嵌套函数重新启用
我刚刚学习 Objective C,遇到了很大的困难。这就是我输入的内容,它给了我一个错误。我输入了粗体文本。有什么问题呢。它在 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;
}
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的问题是 C 及其兄弟不喜欢函数中的函数(暂时搁置
gcc
扩展)。您似乎想要做的是在您的
main
中声明一个全新的main
。这是一个很大的禁忌。我怀疑您已将整个 C 程序剪切并粘贴到现有main
的中间。从:开始
,然后从那里开始努力。
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 yourmain
. 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 existingmain
.Start with:
and work your way up from there.