Compiler Error C2050
switch expression not integral
The switch
expression evaluates to a noninteger value. To resolve the error, use only integral values in switch statements.
The following sample generates C2050:
// C2050.cpp
int main() {
int a = 1;
switch ("a") { // C2050
case 1:
a = 0;
default:
a = 2;
}
}
Possible resolution:
// C2050b.cpp
int main() {
int a = 1;
switch (a) {
case 1:
a = 0;
default:
a = 2;
}
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for