main不是关键字

无聊写的程序,验证些语法知识

#include <stdio.h>
struct main
{
#define MAX_SIZE 19900
int count ;
};
struct super
{
#define MAX_SIZE 100
int count;
char ch;
}
;

int main()
{
struct main hunter;
hunter.count
= MAX_SIZE;
struct super main;
main.count
= MAX_SIZE;
printf(
"Hello World %d \t %d\n",hunter.count,main.count);
return 0;
}

1.struct main来定义,但是不能用if来定义,会出错。

说明main并不是C中关键字,只是作为程序约定以main开始执行——程序的入口。

2.#define的作用域是全局的,编译器会警告重定义,但是可以编译通过,结果为最后一个定义的有效值。

posted @ 2011-05-31 18:12  westfly  阅读(1081)  评论(0编辑  收藏  举报