Question:
What does it mean by "C does not perform any bounds checking on arrays"?
ZIP.
2010-04-18 01:49:22 UTC
what's bound checking?
Five answers:
anonymous
2010-04-18 02:01:52 UTC
It means it doesn't check to see if the array element you're trying to access is even part of the array.



Assume that you have an array with 10 elements called "foo".

foo[20] is legal in C, because it doesn't check the bounds.
Piyush
2010-04-18 02:00:53 UTC
There r two kinds of bounds lower and upper bound......



Lower bound is the first value of an array , by default it is 0.



Upper bound is the last value of the array.....



for e.g. An array of 10 integers (i.e a[10] ) will start from 0 a[0] and with a[9]...



I don't know what is bound checking in C means.....But the above information may help u to find this...
Heatpump
2010-04-18 02:02:42 UTC
unlike Java/C# that checks on the bounds of array before accessing an array member then throws an exception , the C doesn't do that , meanning if you have array of 10 elements and you try to access the 11th element C wouldn't mind , this wil probbably crash your program or yield un defined responses depending on your operation on the 11th element (.i.e. Read OR Write opearation) .



int arrTest[10]; //note arrTest has values from 0-9



if (arrTest[10] >0) {//Do anything} //This will cause a problem during execution but will not throw exception , the problem is that index of 10 doesn't belong to array and hence holds probably a wrong value that will cause problems , and if you try to write on that location you will miss the program somewhere else.
kathie
2016-06-02 13:03:57 UTC
The two statements are related. The first time Doc realizes to accept a badge would be too hypocritical. The second time he is aware of his hypocrisy, but that does not stop him. This leads him to observe that perhaps his hypocrisy does not have limits as he previously asserted.
Sayee
2010-04-18 01:52:46 UTC
means whether its in range or not..

e.g

int value[10];

can hold 10 int values. i.e. value[0], value[1], ....... to value[9]

range is: 0 to 9, upper bound 9, lower bound 0.

Hope it helps


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...