I am writing code for a question which is: Write a method to sort an array of strings so that all the anagrams are next to each other. If my container is vector, it will be
As (like in C) array can be casted to pointer to the first element (but please, do not confuse array with pointer) you can use pointers to determine begin and end, so you write:
sort(strarr, strarr + len, compare);
or if you use C++11 (or Boost) you can use array class:
template
int sortStrarr(std:array& strarr, int len){
sort(strarr.begin(), strarr.end(), compare);
}