Getting last element from vector
View Single Post
you need back(), not end(). end() returns an iterator that points to the next "free" slot.
(found by plugging "c++ vector" into Google, so not a complex query. TFM is always worth an R.)