I am trying to sort an array of strings, but it\'s not sorting anything.... what am I doing wrong?
string namesS[MAX_NAMES];
int compare (const void * a, co
You can use boost::sort, like this:
#include
#include
std::vector stringarray;
boost::sort(stringarray);
If you want use find use boost::find, like this:
std::string findme;
auto offset = boost::find(stringarray, findme) - stringarray.begin()
See 2 useful functions (m_stringarray should be member of ClassA):
const size_t ClassA::GetIdByName(std::string name) const
{
return (boost::find(this->m_stringarray, name) - this->m_stringarray.begin());
}
const std::string ClassA::GetNameById(size_t id) const
{
return this->m_stringarray[id];
}