What will happen if in the C program you assign a value to a array element whose subscript exceeds the size of array?
What will happen if in the C program you assign a value to a array element whose subscript exceeds the size of array?
A. The element will be set to 0.
B. The complier would report an error.
C. The program may crash if some important data gets overwritten
D. The array size would appropriately grow
Hướng dẫn
Chọn C là đáp án đúng
Xem lời giải
Xem lời giải
Khi bạn assign giá trị cho phần tử vượt quá kích thước của mảng. Xảy ra problem là buffer overrun. Có nghĩa là sử dụng vùng nhớ ko hợp lệ (ví dụ: đang lưu giá trị của một biến khác,…), làm cho chương trình bị crash.