int main(int argc,char * argv [])vs int main(int argc,char ** argv) [英] int main(int argc, char *argv[] ) vs int main(int argc, char **argv )
问题描述
这是风格吗?
int main(int argc,char * argv [])或int main(int argc,char ** argv)
ie * argv []或** argv
为什么选择后者?
Hal Styli写道:
这是一个风格的东西吗?
int main(int argc,char * argv [])或int main( int argc,char ** argv)
ie * argv []或** argv
为什么选择后者?
没理由。这两个在函数参数的上下文中是相同的。
我选择一种形式或另一种形式,这取决于我在
程序中如何使用argv。
-
Joe Wright http://www.jw- wright.com
一切都应该尽可能简单,但不要简单。
---阿尔伯特爱因斯坦---
Hal Styli写道:
这是一个风格的东西吗?
int main(int argc,char * argv [])或int main(int argc,char ** argv)
ie * argv []或** argv
是的,它' '风格的东西。
为什么选择后者?
这是一种风格的东西。在正式的参数列表上下文中,char * argv []和
char ** argv的意思完全相同。 (在其他情况下,他们确实没有b $ b。)选择你认为最有意义的那个。我更喜欢**,但是有些
更喜欢* [],并且完全合理地推理他们的偏好,所以我告诉他们他们错了吗?
-
Richard Heathfield: bi ** **@eton.powernet.co.uk
Usenet是一个奇怪的地方。 - Dennis M Ritchie,1999年7月29日。
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K& R答案,C书等:< a rel =nofollowhref =http://users.powernet.co.uk/etontarget =_ blank> http://users.powernet.co.uk/eton
Richard Heathfield写道:
Hal Styli写道:
这是一个风格的东西吗? br />
int main(int argc,char * argv [])或int main(int argc,char ** argv)
ie * argv []或** argv
是的,这是一种风格的东西。
为什么选择后者?
它'是一种风格的东西。在正式的参数列表上下文中,char * argv []和
char ** argv的意思完全相同。 (在其他情况下,他们不会。)选择您认为最有意义的那个。我更喜欢**,但有些人更喜欢* [],并且对他们的偏好有完美合理的推理,那么我是谁告诉他们他们错了?
复制* []超出标准,比思考容易。
-
pete
Is this a style thing?
int main(int argc, char *argv[] ) or int main(int argc, char **argv )
i.e. *argv[] or **argv
Why choose the latter?
Hal Styli wrote:
Is this a style thing?
int main(int argc, char *argv[] ) or int main(int argc, char **argv )
i.e. *argv[] or **argv
Why choose the latter?
No reason. The two are identical in the context of function parameters.
I choose one form or the other depending on how I use argv in the
program.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Hal Styli wrote:
Is this a style thing?
int main(int argc, char *argv[] ) or int main(int argc, char **argv )
i.e. *argv[] or **argv
Yes, it''s a style thing.
Why choose the latter?
It''s a style thing. In a formal parameter list context, char *argv[] and
char **argv mean precisely the same thing. (In other contexts, they do
not.) Choose the one you think is most meaningful. I prefer **, but some
prefer *[], and with perfectly sound reasoning for their preference, so who
am I to tell them they''re wrong?
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Richard Heathfield wrote:
Hal Styli wrote:Is this a style thing?
int main(int argc, char *argv[] ) or int main(int argc, char **argv )
i.e. *argv[] or **argv
Yes, it''s a style thing.Why choose the latter?
It''s a style thing. In a formal parameter list context, char *argv[] and
char **argv mean precisely the same thing. (In other contexts, they do
not.) Choose the one you think is most meaningful. I prefer **, but some
prefer *[], and with perfectly sound reasoning for their preference, so who
am I to tell them they''re wrong?
Copying *[] out of the standard, is easier than thinking.
--
pete
这篇关于int main(int argc,char * argv [])vs int main(int argc,char ** argv)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!