so i could have instead of
lptr->list[pos] < item
could i have
pos instead of lptr->list[pos]? seeing as it gives the position.
well here is the full code:
Code:
void Insert(List *lptr, char item){
int pos, current;
if(IsFull(lptr))
{
fprintf(stderr, "List is full.");
exit(1);
}
for(pos = 0; pos < lptr->count; pos++)
{
if(lptr->list[pos] > item)
break;
}
current = lptr->count - 1;
while (current >= pos)
{
/* Copy the element into the next position along */
lptr->list[current+1] = lptr->list[current];
current--;
}
lptr->list[pos] = item;
lptr->count++;
}
i want to insert an 'item' say EMU at position 2.
how does lptr->[pos] < item work if item is not already in the array, seeing as it compares the positions