Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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
 
PREVIOUS NEXT
Tagged: #access #element #vector
ADD COMMENT
Topic
Name
7+5 =