June 2025
Intermediate to advanced
1093 pages
33h 24m
English
When you write a semicolon where a statement is expected, that is an empty statement. This statement does nothing.
int main() { ;;; // 3 empty statements int number = 12 ; ; // 1 empty statement ; int q = number*number ; // 1 empty statement if(q>50) { q = q - 50; } ; // 1 empty statement std::cout << q << std::endl;}
Listing 8.7 Empty statements everywhere.
Doing nothing is usually completely uncritical. However, there are cases where an inserted empty statement is dangerous. You already know from Chapter 4 that an if is followed by a statement that should be executed if a condition is met. Suppose you insert an empty statement after if(q>50) in the preceding example:
if(q>50) ; { // empty statement with serious ...
Read now
Unlock full access