Compiler Error C2181
TOC
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Error C2181

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;
}
Show:
© 2016 Microsoft