Why are multiple semicolons allowed? [duplicate]
That's because the semicolon, when used alone, represents the empty statement.
The documentation says:
The empty statement consists of a single semicolon. It does nothing and can be used in places where a statement is required but no action needs to be performed.
And provides the following example:
void ProcessMessages()
{
while (ProcessMessage())
; // Statement needed here.
}
Of course, you can execute as many empty statements as you want in sequence, and nothing will happen.
Semicolumn is an empty statement, means "do nothing". Typical example when multiply semicolumns are required is an infinite for loop
for (int i = 0; i < count; ++i) { // <- ordinary for
...
}
for (;;) { // <- infinite (for) loop with no initialization, check and increment
...
}