I've gotten myself into a little confusion regarding the use of const and pointers to pointers of const arrays. Take for example this function:
Code:
void list_alpha(const struct seat ar[])
{
const struct seat** pfull;
int nFull = MAXSEATS - num_empty(ar);
int i, j, count;
const struct seat* temp;
char iname[NAMESIZE * 2];
char jname[NAMESIZE * 2];
pfull = (struct seat**) malloc(nFull * sizeof(struct seat*));
for (i = 0, count = 0; i < MAXSEATS; i++)
if (ar[i].taken)
{
pfull[count] = &(ar[i]);
count++;
}
for (i = 0; i < (count - 1); i++)
for (j = i + 1; j < count; j++)
{
strcpy(iname, pfull[i]->lname);
strcat(iname, pfull[i]->fname);
strcpy(jname, pfull[j]->lname);
strcat(jname, pfull[j]->fname);
if (strcmp(iname, jname) > 0)
{
temp = pfull[i];
pfull[i] = pfull[j];
pfull[j] = temp;
}
}
for (i = 0; i < count; i++)
printf("%d: %s, %s\n", pfull[i]->id, pfull[i]->lname, pfull[i]->fname);
free(pfull);
return;
}
The call to free() at the end brings forth the warning : 'function' : different 'const' qualifiers - and I just can't get my pretty little head around the reason why. Any help?