语法差异 [英] Difference in syntaxes
问题描述
大家好,
有什么区别:
char * f(){}
和
char * f(){}
当我从上面调用上述函数的地方获取值时,语法是什么?
char * buffer = f();
或
char * buffer = f();
我google了它但是dint找到了一个令人满意的答案。以上是什么区别语法。
谢谢和问候,
Rahul
简而言之因为C是一种自由格式的语言,无论你选择哪种风格都可以,而解析器可以区分每个令牌。
请考虑你的情况甚至:
< pre lang =c ++> char * f(){}
它完全等同于其他2 。
这个pe C的特殊性导致了一种非常特殊的比赛,称为 C混淆比赛 [ ^ ]。这个网站将为您提供更多答案,所有其他链接在一起...; - )
请参阅 http: //www.cdecl.org/ [ ^ ]并与之合作你的声明(没有功能体)。
另见在C中,声明指针的正确语法是什么? [ ^ ]。
顺便说一句:我想知道你是懒惰还是什么 - 这是我在谷歌输入你的问题时的首次点击之一...
干杯
Andi
Hi all,
What is the difference between:
char* f(){}
and
char *f(){}
When i will get the value from where i called the above functions what would the syntax be?
char *buffer=f();
OR
char* buffer=f();
I googled it out but dint find a satisfying answer.And what is the difference between the above syntaxes.
Thanks and Regards,
Rahul
In short because C is a free format language, whatever style you choose its ok while the parser can make a distinction of each token.
Please consider that in your case even:
char*f(){}
It's perfectly equivalent top the other 2.
This peculiarity of C lead to a very special type of contest called C obfuscation contest[^]. This site will give you much more answers that all other links together... ;-)
See http://www.cdecl.org/[^] and play with your declarations (without the function body).
See also In C, what is the correct syntax for declaring pointers?[^].
BTW: I wonder if you were lazy or what - this is one of the first hits when I enter your question in Google...
Cheers
Andi
这篇关于语法差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!