分号两端的if语句C和功能 [英] Semicolon at the ends of if-statements and functions in C

查看:92
本文介绍了分号两端的if语句C和功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是碰到了一些code的过度使用分号,或使用分号对于我不知道不同的目的。

I just ran into some code that overuse semicolons, or use semicolon for different purposes that I am not aware of.

我发现在分号if语句的结束,在函数的结束。例如:

I found semicolons at the end of if-statements and at the end of functions. For instance:

  int main (int argc, char * argv[]) {
       // some code

       if (x == NULL) {
           // some code
       };  <-----

       // more code

       return 0;
  }; <---

据与CC,而不是GCC编译。
什么是那些分号呢?我假设是没有区别的,因为编译器将只把它当作空语句。

It is compiling with cc, not gcc. What do those semicolons do? I'm assuming that there is no difference because the compiler would just consider it as empty statement.

推荐答案

他们什么都不做。他们有人的迹象谁不理解的语言非常好,我怀疑。

They do nothing. They're a sign of someone who doesn't understand the language terribly well, I suspect.

如果这是源$ C ​​$ C你名义上的自己,我会删除code和努力与谁写它的人温柔聊天。

If this is source code you notionally "own", I would remove the code and try to have a gentle chat with the person who wrote it.

这篇关于分号两端的if语句C和功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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