a label can only be part of a statement and a declaration is not a statement

Introduction

a label can only be part of a statement and a declaration is not a statement.

Demo

Description

initialization of ‘identifier’ is skipped by ‘case’ label.

Causes

Example

How to fix it ?

the declaration must be enclosed in a block.

Syntax

switch (<  expression of integer type>) {
case <integer onstant-expression> :
statement(s);
break; /* optional */

case <integer onstant-expression> :
statement(s);
break; /* optional */

/* you can have any number of case statements */
default : /* Optional */
statement(s);
}

Notes

See also

Subscribe to our channel.

Leave a Reply

Your email address will not be published. Required fields are marked *