So I'm passing a char Array(En) that consists a few words and I'm trying to sort alphabetically. Unfortunately, my compiler explodes with " int strcmp(const char *,const char *)' : cannot convert argument 1 from 'char' to 'const char *" and I'm kinda stuck!
void TDihotTable::Set(char *En){
int i, j;
bool sorted = false;
char* pTemp = NULL;
while (!sorted)
{
sorted = true;
for (size_t i = 0; i < 6 - 1; ++i)
{
if (!strcmp(En[i], En[i + 1]) > 0)
{
sorted = false;
pTemp = En[i];
En[i] = En[i + 1];
En[i + 1] = pTemp;
}
}
}
}
Your function should look more like:
void TDihotTable::Set(char **En){
^^
That would be a array of pointers to string, which you can strcmp like you done in
if (!strcmp(En[i], En[i + 1]) > 0)
^
which is als so buggy at the mark. use
if (strcmp(En[i], En[i + 1]) > 0)
at the moment you try to compare single characters.