为什么return会导致非法语法? [英] why return causes an Illegal syntax??

查看:84
本文介绍了为什么return会导致非法语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

main(int argc,char * argv [])

{

(main&& argc)? main(argc-1,NULL):返回0; //第1行

}


1.我能否知道为什么使用return会导致非法语法...我猜它

与命令行参数有关..

2.任何人都可以解释第1行吗?它有点令人困惑....

main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0; //line 1
}

1. Can I know why using return causes an illegal syntax...I guess it
has something to do with command line arguments..
2. can anyone explain the line 1?? its a bit confusing....

推荐答案

ch ******* @ yahoo.com 写道:
main(int argc,char * argv [])
{
(主&& argc)? main(argc-1,NULL):返回0; //第1行
}

1.我能否知道为什么使用return会导致非法语法...我猜它
与命令行参数有关..
2.谁能解释一下1号线?它有点令人困惑....
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0; //line 1
}

1. Can I know why using return causes an illegal syntax...I guess it
has something to do with command line arguments..
2. can anyone explain the line 1?? its a bit confusing....



1.不,这是因为`return''是一个陈述,而不是表达。

2简单语法错误。下一个?


- g

-

Artie Gold - 德克萨斯州奥斯汀
http://goldsays.blogspot.com
http://www.cafepress.com/goldsays

如果你无需隐藏,你我没有尝试!


1. No, it''s because `return'' is a statement, not an expression.
2. Simple. Syntax error. Next?

--ag
--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com
http://www.cafepress.com/goldsays
"If you have nothing to hide, you''re not trying!"


我的意思是声明的第一部分(主要&& argc)是什么?

main (argc-1,NULL):返回0;

确实... IGNORE返回的存在...

I meant what does first part of the statement (main && argc) ?
main(argc-1, NULL) : return 0;
does...IGNORE THE PRESENCE OF return...


2006年1月17日07:15:34 -0800,在comp.lang.c中,ch ******* @ yahoo.com

< ch ***** **@yahoo.com>写道:
On 17 Jan 2006 07:15:34 -0800, in comp.lang.c , "ch*******@yahoo.com"
<ch*******@yahoo.com> wrote:
main(int argc,char * argv [])
{
(main&& argc)? main(argc-1,NULL):返回0; //第1行
}

1。我能否知道为什么使用return会导致非法语法...


三元运算符的操作数必须是同一类型,例如两者都是
numeric,两个相同的结构类型,两个指向相同类型的指针,

都是void等等。return 0没有类型,与

类型的main()不一样是int。


写这个的正确方法(这是一个例子)一个递归的

main,而且在C ++中是违法的))


return(main&& argc)? main(argc-1,NULL):0;

与命令行参数有关..
2。任何人都可以解释这条线路吗??它有点令人困惑....
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0; //line 1
}

1. Can I know why using return causes an illegal syntax...
The operands of the ternary operator must be of the same type, eg both
numeric, both the same struct type, both pointers to the same type,
both void, etc etc. "return 0" has no type and is not the same as the
type of main() which is int.

The correct way to write this (which is an example of a recursive
main, and illegal in C++ by the way) ) is

return (main && argc) ? main(argc-1, NULL) : 0;
has something to do with command line arguments..
2. can anyone explain the line 1??
its a bit confusing....




你在哪里得到这个垃圾?这是你发布的第三个完全无意义的代码

代码。你想做什么?


另外,当发布到CLC时,你应该发布#include任何

相关标题的片段。在这种情况下,你需要一些东西来定义NULL。

马克麦金太尔

-


---- ==发表通过Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News == ----
http: //www.newsfeeds.com 世界排名第一的新闻组服务! 120,000多个新闻组

---- =东海岸和西海岸服务器农场 - 通过加密实现全隐私= ----



Where do you get this rubbish? This is the third total nonsense bit
of code you''ve posted. What are you trying to do?

Also, when posting to CLC, you should post snippets which #include any
relevant headers. In this case, you need something to define NULL.
Mark McIntyre
--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


这篇关于为什么return会导致非法语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆