我想确切地知道,C语言中的null语句是什么?并解释它的典型用法。
我找到了以下代码段。
for (j=6; j>0; j++)
;
和
for (j=6; j>0; j++)
最佳答案
来自 msdn 页面:
The "null statement" is an expression statement with the expression missing. It is useful when the syntax of the language calls for a statement but no expression evaluation. It consists of a semicolon.
Null statements are commonly used as placeholders in iteration statements or as statements on which to place labels at the end of compound statements or functions.
了解更多:https://msdn.microsoft.com/en-us/library/1zea45ac.aspx
And explain a typical use of it.
当你想查找字符串中某个字符第一次出现的索引时
int a[50] = "lord of the rings";
int i;
for(i = 0; a[i] != 't'; i++)
;//null statement
//as no operation is required
关于c - 什么是 C 中的空语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40440400/