can any one explain me more about arrys?

how can i write past the end of an arry
Use std::vector<> instead of an array. https://cal-linux.com/tutorials/vectors.html
you can't.
Vectors are the way to go.

The best C++ has if you cannot use vectors for some reason is to reallocate a pointer that acts like an array using C statements. Or, you make your array so big you never run out of space in it for (second guessing the user's behavior with a double dose of common sense and paranoia). If the user exceeds the guessed max size, tell them about it and refuse to comply.




In a regular array, you cannot go past the end of the array because you declare the size of the array before you create the array. You can use a dynamically allocated array, and if that's full, you create a new array with a bigger capacity, store the information from the old array into the new array, and delete the old array. Doing a this is essentially the same as using a vector.
*Actually, you totally can write past the end of the array, and in some contexts it is perfectly valid to do so.

What you can't do is write to memory you don't own without danger of making something unpleasant happen.

**Agree with JLBorges, use a std::vector.
thanks that was helpful
Topic archived. No new replies allowed.