i just want to know if subscript is greater than the size of array then either this value is stored outside of the memory located to array or sometimes do not saved and poduces error
can you tell how and by whom this is decided what action to be taken

Recommended Answers

All 3 Replies

> can you tell how and by whom this is decided what action to be taken
Yes, the troll under the bridge eats your code.

actualy,
if the subscript is greater than the size of the array
2 things can happen:
1. the value will be storred in the next memory location, calculated by the index, so if v[10] is a vector, than v is the address of its first element, and v is *(v+i) so v[11] is *(v+11). if in that location is another variable, its value will be overwritten.
2. it will produce a segmentation fault or something like that if that memory location cannot be written, that is it is outside the zone allocated for your process

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.