Answers for "how to access the last element of the vector"

C++
22

access last element in vector in c++

vector<int> v;
cout << v[v.size() - 1];
cout << *(v.end() - 1);
cout << *v.rbegin();
// all three of them work
Posted by: Guest on May-31-2020
0

c++ last element of vector

int var = vec.back().c;
Posted by: Guest on January-05-2022

Code answers related to "how to access the last element of the vector"

Browse Popular Code Answers by Language