Illegal else without matching if visual c++ lỗi năm 2024

Aġġorna għal Microsoft Edge biex tieħu vantaġġ mill-aħħar karatteristiċi, aġġornamenti tas-sigurtà, u appoġġ tekniku.

Compiler Error C2181

  • Artiklu
  • 08/03/2021

F'dan l-artiklu

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;
}


Feedback

Din il-paġna kienet utli?

Feedback

Disponibbli dalwaqt: Matul l-2024 se nkunu qed inwaqqfu gradwalment Problemi GitHub bħala l-mekkaniżmu ta’ feedback għall-kontenut u se nibdluh b’sistema ġdida ta’ feedback. Għal aktar informazzjoni, ara: https://aka.ms/ContentUserFeedback.

Issottometti u ara feedback għal

Riżorsi addizzjonali

F'dan l-artiklu

Dưới đây là một số lỗi cú pháp thường gặp. Các bạn tìm xem bạn có phạm lỗi nào không nhé.

Tên lỗi

Giải thích

Hình minh họa

Cách sửa

Illegal default:

default đặt không đúng

1a

1b

Illegal else without matching if

Dùng else mà không có if

2a

2b

Illegal continue

Lệnh continue không nằm trong vòng lặp

3a

3b

‘ ‘: identifier not found:

Hàm ‘ ‘ chưa được khai báo

4a

4b

‘ ‘: undeclared identifier

Biến ‘ ‘ chưa khai báo

5a

5b

The variable ‘ ‘ is being used without being initialized

Biến ‘ ‘ chưa nhận giá trị

6a

6b

End of file found before the left brace ‘{‘ at [link] was matched

Thiếu ‘{‘ ở cuối chương trình

7a

7b

‘=’: left operand must be l-value

Thiếu ‘=’ trong so sánh

8a

8b

Cannot assign to a variable is const

Không thể thay đổi giá trị hằng

9a

9b

Too many characters in constant

Nhiều hơn 1 ký tự trong ‘ ‘

10a

10b

Cannot convert from ‘type 1’ to ‘type 2’

Không thể chuyển đổi từ ‘kiểu 1’ sang ‘kiểu 2’

11a

11b

Function does not take arguments:

Đối số hàm không đúng

12a

12b

Must return a value

Chưa trả về giá trị của hàm

13a

13b

Ambiguous call to overload function

Không phân biệt được 2 hàm trùng tên

14a

14b

Integer division by zero

Chia cho 0

15a

15b

‘ ‘: redefinition

‘ ‘ biến ‘ ‘ được khai báo nhiều lần

16a

16b

Illegal else without matching if visual c++ lỗi năm 2024
Illegal else without matching if visual c++ lỗi năm 2024
Illegal else without matching if visual c++ lỗi năm 2024
Illegal else without matching if visual c++ lỗi năm 2024