Home  >  Article  >  Backend Development  >  Are empty statements not allowed in C source programs?

Are empty statements not allowed in C source programs?

青灯夜游
青灯夜游Original
2020-07-15 15:48:406703browse

Empty statements are allowed in c source programs. The empty statement is a special statement in C language or C; if a statement has only one semicolon ";", it is called an empty statement. In programs, empty statements are mainly used to empty loop bodies.

Are empty statements not allowed in C source programs?

# Empty statements are allowed in c source programs.

In C language or C, there is a special statement called an empty statement.

In C language or C, if a statement has only one semicolon ";", it is called an empty statement. To put it simply, there is no execution code, only a ";" semicolon to mark the end of the statement.

The empty statement is a statement that executes nothing. In the program, the empty statement is mainly used to empty the loop body, such as:

while(getchar()!='\n');

The function of this statement is to require the user to re-enter as long as the character entered from the keyboard is not a carriage return. That is, the user is required to press Enter before continuing with the subsequent program. In this part of the code, receiving the user's keystrokes and judging the contents of the keystrokes are all concentrated in the while judgment. Therefore, there is no need to perform any functions in the loop body. Just inside the loop body, enter an empty statement as the loop body.

Recommended: "c Language Tutorial"

The above is the detailed content of Are empty statements not allowed in C source programs?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn