Reputation: 1364
Imagine these:
int main (void)
{
int V[101];
populateSomehow(V);
std::sort(V, &V[100]); //which one
std::sort(V, V+100);
}
Is there a 'safer one'?
Upvotes: 0
Views: 164
Reputation: 3325
There is another way in C style:
int V[101];
std::sort(V, V + sizeof(V)/sizeof(V[0]));
Upvotes: 1
Reputation: 23654
You can use std::begin
and std::end
since c++ 11. For example:
int V[100];
std::sort(std::begin(V), std::end(V));
Upvotes: 4