Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize Array out of bounds in C language

Shulou Source: shulou.com Published: 2022-06-01 03:06:28 09月19日 Update

This article is to share with you about how the C language implements array out of bounds. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Array out of bounds

The subscript of an array is limited in scope.

The lower stipulation of the array starts at 0, and if the array has n elements, the subscript of the last element is nMel 1.

So if the subscript of the array is less than 0 or greater than nMel 1, the array is out of bounds and beyond the legal space of the array.

The C language itself does not cross the bounds of the array subscript, and the compiler does not necessarily report an error, but the fact that the compiler does not report an error does not mean that the program is correct.

Rows and columns of a two-dimensional array may also be out of bounds.

So when programmers write code, it's best to check out of bounds themselves.

# include int main () {int item0; int arr [] = {1, 2, 4, 5, 6, 8, 9, 10}; for (iMag0; I

Tags: Array subscript compiler compiler language variable address that is local space code element content more program article loop check different good Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MariaDB MySQL NVidia Apple