Export (0) Print
Expand All
Expand Minimize

Compiler Error C2181

Error Message

illegal else without matching if

Each else must have a matching if.

The following sample generates C2181:

// C2181.cpp
int main() {
   int i = 0;
   else   // C2181
      i = 1;
}

Possible resolution:

// C2181b.cpp
int main() {
   int i = 0;
   if(i)
      i = 0;
   else
      i = 1;
}

Community Additions

ADD
Show:
© 2015 Microsoft