将全局变量赋予函数 [英] Paasing global variables to functions
问题描述
大家好
在很多地方我都看到程序员将全局变量
传递给c中的函数。我无法弄清楚他们为什么会这样做。需要
这方面的一些线索。在某个地方,我听说这个哲学来自
对象的世界,但它是否适用于c?
Hi all
At many places I have seen that programmers pass global variables
to functions in c. I am not able to figure out why they do so. need
some clues on this. somewhere i heard that this philosophy is from
object orieted world but is it applicable for c?
推荐答案
an********@gmail.com 写道:
an********@gmail.com wrote:
大家好吧
在很多地方我都看到程序员将全局变量传递给c中的函数。我无法弄清楚他们为什么会这样做。
永远不要低估盲目愚蠢的压倒性力量。
需要一些关于此的线索。在某个地方我听说这个哲学来自对象世界,但是它适用于c吗?
Hi all
At many places I have seen that programmers pass global variables
to functions in c. I am not able to figure out why they do so.
Never underestimate the sheer overwhelming power of mindless stupidity.
need
some clues on this. somewhere i heard that this philosophy is from
object orieted world but is it applicable for c?
全球思考。当地法案。
-
Richard Heathfield
Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk
邮件:rjh在上面的域名
Think global. Act local.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
mail: rjh at above domain
一个******** @ gmail.com 写道:
在很多地方,我看到程序员将全局变量传递给函数C。我无法弄清楚他们为什么会这样做。需要一些关于此的线索。某个地方我听说这个哲学来自于对象世界,但是它适用于c吗?
At many places I have seen that programmers pass global variables
to functions in c. I am not able to figure out why they do so. need
some clues on this. somewhere i heard that this philosophy is from
object orieted world but is it applicable for c?
例如,该函数被多次调用不同的
参数比特定的全局变量。例如:
f(myglobal);
f(mylocal);
f(myglobal2);
for instance, the function is called multiple times with different
arguments than that specific global variable. eg:
f(myglobal);
f(mylocal);
f(myglobal2);
an********@gmail.com 写于28/07/05:
an********@gmail.com wrote on 28/07/05 :
在很多地方,我看到程序员将全局变量
传递给c中的函数。
At many places I have seen that programmers pass global variables
to functions in c.
听起来很奇怪。如果一个变量有一个全局范围,它就不一致了
将它传递给一个函数(通过参数,我猜)......
也就是说,更好地避免全局范围变量...
-
Emmanuel
C-FAQ: http://www.eskimo.com/~scs/ C-faq / faq.html
C库: http://www.dinkumware.com/refxc.html
今天世界上有10种人;
那些了解二元的人,以及那些不懂的人。
Sounds weird. If a variable has a global scope, it''s inconsistent to
pass it to a function (via a parameter, I guess)...
That said, better to avoid global scope variables at all...
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html
"There are 10 types of people in the world today;
those that understand binary, and those that dont."
这篇关于将全局变量赋予函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!