且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

主要是注册单词

更新时间:2022-10-30 15:07:57

small TUX写道:

Hello程序员;

我今天加入了。任何人都可以说

关于单词main,它是一个注册单词,证明你的问题

也。我想指出一件事,我们可以使用名称main来制作变量




`main''不是关键字,'main''不是保留的

标识符。有可能(虽然有悖常理)使用`main''

作为宏,变量,结构或

联合标记的名称,或者...


#include< stdio.h>

int main(void){

const char * main = world;

printf(" Hello,%s!\ n",main);

#define main 0

返回主页;

}


(不推荐。)


-

Eric Sosman
es*****@acm-dot-org.inva lid


Eric Sosman< es ***** @ acm-dot-org.invalidwrites:

small TUX写道:

> Hello程序员;
我今天加入了。任何人都可以说
关于main这个词,它是一个注册词,也证明了你的问题。我想指出一件事,我们可以用名称main来制作变量



`main''不是关键字,'main''不是保留的

标识符。有可能(虽然有悖常理)使用`main''

作为宏,变量,结构或

联合标记的名称,或者...


#include< stdio.h>

int main(void){

const char * main = world;

printf(" Hello,%s!\ n",main);

#define main 0

返回主要;

}


(不推荐。)



怎么样主叫作为常规功能?

例如:


#include< stdio.h>


int main( void)

{

printf(" hello");

main();

return(0 );

}


它使用gcc进行无限递归,但我想我听说过你

可以不要叫main,所以这是一个未定义的行为吗?


-

Simias

email rot13-ified


文章< 86 ************ @ simias.hd.free.fr>,

Simias< fv ****** @ tznvy。 pbzwrote:

>它使用gcc进行无限递归,但我想我听说你不能称为main,所以这是一个未定义的行为?



不,调用main()是完全合法的。


我想不到任何相反,

调用另一个函数的情况。 main()的参数旨在便于访问命令行参数,并且这不太可能是一个有用的内部接口。

是一个有用的内部接口。


- Richard


-

应考虑到需要多少人一些字母表中包含32个字符

" - 1963年的X3.4。


Hello programmers;
I joinded today itself. Can anyone say
about the word main, is it a registered word, justify your question
also. I would like to point about one thing that we can make variables
with name main.
Thanks.

small TUX wrote:
Hello programmers;
I joinded today itself. Can anyone say
about the word main, is it a registered word, justify your question
also. I would like to point about one thing that we can make variables
with name main.

`main'' is not a keyword, and `main'' is not a reserved
identifier. It is possible (although perverse) to use `main''
as the name of a macro, or of a variable, or of a struct or
union tag, or ...

#include <stdio.h>
int main(void) {
const char *main = "world";
printf ("Hello, %s!\n", main);
#define main 0
return main;
}

(Not recommended.)

--
Eric Sosman
es*****@acm-dot-org.invalid


Eric Sosman <es*****@acm-dot-org.invalidwrites:
small TUX wrote:
>Hello programmers;
I joinded today itself. Can anyone say
about the word main, is it a registered word, justify your question
also. I would like to point about one thing that we can make variables
with name main.


`main'' is not a keyword, and `main'' is not a reserved
identifier. It is possible (although perverse) to use `main''
as the name of a macro, or of a variable, or of a struct or
union tag, or ...

#include <stdio.h>
int main(void) {
const char *main = "world";
printf ("Hello, %s!\n", main);
#define main 0
return main;
}

(Not recommended.)

And what about calling main as a regular function?
e.g.:

#include <stdio.h>

int main(void)
{
printf("hello");
main();
return (0);
}

It makes an infinite recursion with gcc, but i think i''ve heard that you
can''t call main, so is this an undefined behaviour?

--
Simias
email rot13-ified


In article <86************@simias.hd.free.fr>,
Simias <fv******@tznvy.pbzwrote:
>It makes an infinite recursion with gcc, but i think i''ve heard that you
can''t call main, so is this an undefined behaviour?

No, it''s perfectly legal to call main().

I can''t think of any cases where it wouldn''t be clearer to instead
call another function though. main()''s arguments are intended to be
convenient for accessing command line arguments, and that''s unlikely
to be a useful internal interface.

-- Richard


--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.